Problems with std.time and local conversion?

Bernard Helyer b.helyer at gmail.com
Fri Apr 16 06:54:34 PDT 2010


On 17/04/10 01:12, fawcett at uwindsor.ca wrote:
> On 10-04-16 09:03 AM, fawcett at uwindsor.ca wrote:
>> On 10-04-15 05:10 PM, Jesse Phillips wrote:
>>> This bug was reported:
>>>
>>> http://d.puremagic.com/issues/show_bug.cgi?id=2965
>>
>> Ah, thank you. I see that importing std.datebase does indeed give
>> better results, though still not perfectly so:
>>
>> #!/usr/bin/dmd -run
>>
>> import std.datebase;
>> import std.stdio;
>> import std.date;
>>
>> void main() {
>> // UTC first, then local
>> writefln("UTC: %s", toString(getUTCtime()));
>> writefln("Local: %s", toString(UTCtoLocalTime(getUTCtime())));
>> }
>>
>> $ TZ=EST5EDT ./timedemo.d
>> UTC: Fri Apr 16 08:56:04 GMT-0400 2010
>> Local: Fri Apr 16 04:56:04 GMT-0400 2010
>>
>> The time is right, but the the tzoffset is wrong.
>
> Correction to my observation: the time component is messed up too, it
> was 08:56 local time when I ran this, not 04:56.
>
>> That's not quite what #2965 is reporting, so I'll file a new issue.
>
> ...which I'll still do.
>
> Best,
> Graham


Yeah, I found std.date to be completely broken, too. Sometimes UTC is 
localtime, and sometimes localtime is UTC, DST is wrong, the list goes 
on and on and on. I think that until the bugs are fixed, std.date should 
be removed from Phobos as it is almost impossible to use it and not hit 
a bug. I feel the same way about std.xml.



More information about the Digitalmars-d mailing list