std.date

Jonathan M Davis jmdavisProg at gmx.com
Tue Nov 16 11:42:35 PST 2010


On Tuesday, November 16, 2010 11:11:05 Steve Teale wrote:
> I have moaned several times about the fact that this module does not have a
> method for creating a date from the system clock.
> 
> It provides a parse method to convert a string in a limited number of
> formats. In the course of doing that, it calls the OS primitive to get the
> time zone offset.
> 
> So why the omission? If it's going to use the OS, why not go the whole hog.
> 
> It also strikes me as odd that it does not include a table of leap seconds.
> As it stands, some of its methods could return values that were out by a
> year for up to four or five seconds on January 1 2011. I'm no expert on
> UTC, Gregorian Calendar and such, so I could well be wrong, but ....
> 
> Phobos doesn't really need the burden of such tasks. Most OS's provide
> regular upgrades that cover this stuff.

As Steven points out, I've been working on a date/time module which will become 
std.datetime once its review process is finished. It's far more advanced than 
std.date.

However, I would point out though that virtually nothing computer-wise cares 
about leap seconds. Posix even specifically ignores them. This currently means 
that UTC according to your typical computer is technically 24 seconds off of UTC. 
But for the most part, since they all ignore leap seconds, it's not an issue. 
However, with the future std.datetime, if you use PosixTimeZone with a time zone 
which has leap seconds (which are generally the ones whose names start with 
"right/"), you can have leap seconds.

In any case, feel free to try out the code and comment on it. The most recent 
thread on it is "datetime review part 2," so please post any comments that you 
have on it there. The most recent code which I've posted can be found here: 
http://is.gd/gSwDv

HTML documentation for it can be found in the Doc folder while the source is in 
Src. It should be a huge step up from using std.date (which is highly buggy at 
present regardless of whether the design as any good or not).

- Jonathan M Davis


More information about the Digitalmars-d mailing list