date and time

Jonathan M Davis jmdavisProg at gmx.com
Sat Sep 25 18:21:21 PDT 2010


On Saturday 25 September 2010 17:48:54 Joel Christensen wrote:
> I've tried that module.
> 
> I was putting:
> long dt = UTCtoLocalTime(getUTCtime - (msPerDay / 2));
> Then when daylight savings came it was wrong, (computer was right mind).
> 
> long datetime = UTCtoLocalTime(getUTCtime);
> It is 1 hour and half a day out. It was the right hour till daylight
> savings. I live in New Zealand.
> 
> Some one said that module was a mine field.

std.date is definitely broken. Some of it works, much doesn't. It is going to be 
replaced by std.datetime which will have much better functionality for both 
times and dates, but that hasn't been finished yet. Both Yao G. and I are working 
on implementations which are going to be reviewed for possible inclusion in 
phobos as std.datetime, and we're getting close to being done, but as I said, 
it's not finished yet.
 
So, your best bet is to either mess around with std.date and figure out if you 
can get the functionality you need to work one way or another (I think that I 
ended up only ever using UTC in my code that used std.date since I couldn't get 
it to properly print local time), or you can use the C API directly: 
http://www.cppreference.com/wiki/c/date/start

I believe that core.sys.posix.time.d already has the appropriate prototypes for 
them in D (on posix systems at least).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list