[phobos] Status of std.gregorian
Jonathan M Davis
jmdavisprog at gmail.com
Sat Aug 14 18:00:31 PDT 2010
I was wondering about the current status of std.gregorian. It's listed on the
left hand side of the docs on the digital mars website, but the actual page
isn't there. Looking at the current code, there are a lot of functions which are
stubbed out with no code other than assert(0). Is anyone actively working on it?
As for its design, it looks like it's holding the number of days as a ulong with
nothing more precise than that. I would have expected a time_t or equivalent
with the number of seconds or milliseconds since the epoch. So, that makes it
look like it doesn't care about anything more precise than days, which would be
insanely limiting if it's supposed to be replacing the buggy std.date.
I'm not quite sure what the overall design plan is for std.gregorian, but due to
having to deal with various time-related issues at work, I'm 100% convinced that
the correct way to write time code is to have _everything_ in UTC until you
actually need it in local time, and at that point you do a conversion (likely to
a string); the time/date class however would _always_ be in UTC internally. I've
seen way too many timezone and DST issues to think that any other way of doing
it makes sense. time_t is always in UTC, though unfortunately most of the posix
functions (and likely Windows API functions as well) translate to local time
when converting time_t to anything else, which makes it quite easy to introduce
conversion bugs into code (especially when DST rolls around).
In any case, what's the current game plan for std.gregorian? I'm willing to work
on it help is needed, though as I said, I'd be highly interested in a design
which retains UTC for everything until you ask for local time (or at minimum
really kept its internals as UTC even if most of the functions were giving you
information related to local time), and I don't get the impression that that was
quite what std.gregorian is currently designed to do (though it doesn't even
seem to include seconds, let alone milliseconds, so I'm not quite sure what the
goal of std.gregorian is). Honestly, if there is no time stuff in Phobos which
always retains its time in UTC, I'm likely to go and write my own which does,
because I'm so sick of time-related bugs in the code that I've dealt with.
- Jonathan M Davis
More information about the phobos
mailing list