On Fri, 20 Feb 2009, David Green wrote:

On 2009-Feb-19, at 11:26 am, Dave Rolsky wrote:
What I want to see in Perl 6 is a set of very minimal roles that can be used to provide a simply object from gmtime() and localtime(). These objects should not handle locales, proper Olson timezones, string parsing, user-defined formatting, or math.

Yes; I myself haven't had to worry about leap-seconds before, and may very well never have to. Really basic math is common enough that it seems reasonable to include, though. And we get that by being able to numify times, though I'm not sure about officially making time() return a Num -- isn't that exposing an implementation detail? If I need an epoch value, I'd expect to have to say $time.epoch or $time.epoch(1970) or something.

Define really basic math. I don't think there is such a thing. DateTime math is complex. Attempts to make it less complex end up making it much harder on the end user. For example, you could say "all math is done in terms of seconds", but then there's literally no way to "add 1 month".

our Time::localtime(:$time,:tz<GMT>)

Why can't we just have time() that takes a :tz adverb and dispense with gmtime() and localtime()? I also think that timezones should be required, so that it's impossible to have a time and not know what TZ it's supposed to be.

Duh, I dunno. I'll leave that to @Larry to decide. Honestly, I'm much more interested in the roles than the built-in interface.

If there's no "simple enough" way to do minimal timezones, then allow only GMT (and require using a suitable module to recognise any other TZ). If you really don't care because you know for sure the TZ will never matter, say "use timezone <GMT>". (You may as well not care that all the times are GMT in that case. But if it turns out someday that you do care, you can't say you didn't know.)

As I said in the spec, you _can_ get an observance for a given epoch value quite easily. This tells you the offset from UTC, whether DST is in effect, and a short name identifier (like CST).

What you can't get easily in a cross-platform manner is a hook into the associated set of rules that defines all the timezone transitions in effect.

Or maybe allow any string as a timezone by default. If all your times use the same TZ, that's fine; but as soon as you try to work with two times with different zones, you'll get an error, unless you're using a module that knows how to convert between those zones.

If there is a UTC epoch stored/calculable in each object, you can compare them safely.


-dave

/*============================================================
http://VegGuide.org               http://blog.urth.org
Your guide to all that's veg      House Absolute(ly Pointless)
============================================================*/

Reply via email to