AltME: Ren - Time & Duration


The reason I'm OK with the 0:15 limitation in v1 is that we can later relax the constraint without breaking data. In general, I want to let people express their data, even if it may not make sense to us right now. We say what a type of value looks like, but impose few semantic restrictions.
Timezones are crazy stuff, there were not quarter hour based timezones in the past and there's no reason to not expect them in the future.
TZ - Agreed, it has to be treated as  filter/list that will change, and piss us all off.
(Windows changed the defaults between Windows 7 and 8,  names of cities also change, and so does the geographical location of the splits)
Time & Duration is a big topic to handle.   IEEE should have a library for this.  Excel SUCKS for this of note
+1 for 0:01 timezone support.
A little research, for comparison. (long message)
A Duration represents the elapsed time between two instants as an int64 nanosecond count. The representation limits the largest representable duration to approximately 290 years.
ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
  func Date
    func Date(year int, month Month, day, hour, min, sec, nsec int, loc *Location) Time
    Date returns the Time corresponding to yyyy-mm-dd hh:mm:ss + nsec nanoseconds in the appropriate zone for that time in the given location. The month, day, hour, min, sec, and nsec values may be outside their usual ranges and will be normalized during the conversion. For example, October 32 converts to November 1.
For example, "P3Y6M4DT12H30M5S" represents a duration of "three years, six months, four days, twelve hours, thirty minutes, and five seconds".
To resolve ambiguity, "P1M" is a one-month duration and "PT1M" is a one-minute duration (note the time designator, T, that precedes the time value). The smallest value used may also have a decimal fraction, as in "P0.5Y" to indicate half a year. This decimal fraction may be specified with either a comma or a full stop, as in "P0,5Y" or "P0.5Y". The standard does not prohibit date and time values in a duration representation from exceeding their "carry over points" except as noted below. Thus, "PT36H" could be used as well as "P1DT12H" for representing the same duration.
A Duration object is measured in seconds or nanoseconds and does not use date-based constructs such as years, months, and days, though the class provides methods that convert to days, hours, and minutes. A Duration can have a negative value
To define an amount of time with date-based values (years, months, days), use the Period class...The total period of time is represented by all three units together: months, days, and years.
In versions prior to Ruby 1.9 and on many systems Time is represented as a 32-bit signed value describing the number of seconds since January 1, 1970 UTC, a thin wrapper around a POSIX-standard time_t value, and is bounded
Since Ruby 1.9.2, Time implementation uses a signed 63 bit integer, Bignum or Rational. The integer is a number of nanoseconds since the Epoch which can represent 1823-11-12 to 2116-02-20. When Bignum or Rational is used (before 1823, after 2116, under nanosecond), Time works slower as when integer is used.
Duration object is stored as seconds.
A TimeSpan object represents a time interval (duration of time or elapsed time) that is measured as a positive or negative number of days, hours, minutes, seconds, and fractions of a second. The TimeSpan structure can also be used to represent the time of day, but only if the time is unrelated to a particular date.
The largest unit of time that the TimeSpan structure uses to measure duration is a day. Time intervals are measured in days for consistency, because the number of days in larger units of time, such as months and years, varies.
The value of a TimeSpan object is the number of ticks that equal the represented time interval. A tick is equal to 100 nanoseconds, or one ten-millionth of a second. The value of a TimeSpan object can range from TimeSpan.MinValue (The string representation of this value is negative 10675199.02:48:05.4775808, or slightly more than negative 10,675,199 days.) to TimeSpan.MaxValue (The string representation of this value is positive 10675199.02:48:05.4775807, or slightly more than 10,675,199 days.).
TimeDelta - Only days, seconds and microseconds are stored internally...Note that normalization of negative values may be surprising at first.
- The most negative timedelta object, timedelta(-999999999).
- The most positive timedelta object, timedelta(days=999999999, hours=23, minutes=59, seconds=59, microseconds=999999).
- The smallest possible difference between non-equal timedelta objects, timedelta(microseconds=1).
- seconds: Between 0 and 86399 inclusive
Just for fun:
- Planck time: 0:0:0.0000000000000000000000000000000000000000000054
- Age of universe: 0:0:432'000'000'000'000'000
I know this is a long discussion but, it's such an important element, I think it's worth it.
- I don't like the ISO8601/iCal/Go format for durations. e.g., "P3Y6M4DT12H30M5S"
- I DO want a dialect or lexical that lets us express units, but now is not the time, as Doc says.
- I think we should support large relative date-time values.
Also, I should note that I use Doc's scheduler library, and extended it a bit. The period/interval dialect there works well in that context.
Rebol's solution to relative time values is to use two datatypes: time!, allowing large non-sexagesimal values and normalizing them on load, and integer! which is the number of days between two dates. This maps reasonably well to the .NET and Python approaches, and makes sense if we want unambiguous offset values (because month and year lengths vary). That doesn't mean we can't support separate YMD values in a lexical format, just that we need to say what they mean to Ren.
I shouldn't say non-sexa* values, as it does treat them as such. I mean overflow values.
"we need to say what they mean to Ren." By this, I mean is 4 years the same as 1460 days, 1461 days, or neither and the math is up to you?
Absolute and relative date-time informative rules:
Basically, constrain absolute values, don't allow timezone on relative values, and require a sign on relative date and date-time values to distinguish them from absolute. Relative time values do NOT require a sign, with the expectation that time-of-day would not be an independent value type.
Is this getting us closer or further away? It doesn't answer constraint questions, like a 4 digit limit on abs years, large values in relative parts, or minimizing overhead. Does it need to?

Does anyone object to this group being [web public]?
web-public: Fine with me.
The absolute / relative date/time proposal up on looks quite good. A few thoughts after first digesting it for a bit:
Standalone times as relative times: +1
Basic constraints for month and day value ranges in date and time-of-day/seconds: +1
Standalone relative dates don't strike me as something particularly worthy of providing, at first glance.
I also think that the forced sign looks rather awkward for negative rel-dates: -1-1-1, -10-0-1. Further, I think that date arithmetic with relative dates may be _really_ awkward.
So I'd suggest limiting any-data-time to just abs-date-time or abs-date or rel-time, for starters.

Last message posted 119 weeks ago.