std.date again
Carlos Santander
csantander619 at gmail.com
Mon May 15 11:37:11 PDT 2006
Walter Bright escribió:
> Carlos Santander wrote:
>> No, I'm saying the UTC result on linux is the correct local result.
>
>
> It's hard for me to debug this, because it works in my timezone. Want to
> give it a try in yours?
I'm completely confused about this whole thing, and I think the problem is
documentation.
-- On linux (DMD):
If I do toUTCString(getUTCtime()) I correctly get:
Mon, 15 May 2006 17:58:57 UTC
But when I do toTimeString(getUTCtime()) I get:
12:58:57 GMT-0500
So I think toTimeString must be wrong, my logic being that I asked it to return
the current time as UTC time. But what it returned was the time for my local
timezone. However, it's never explicitly stated that it should behave that way.
-- On mac (GDC):
It's the same as linux, but the timezone seems to be doing the opposite:
UTC :Mon, 15 May 2006 18:07:44 UTC
Local:04:07:44 GMT+0500
So it performed an addition instead of a difference.
-- On windows (DMD):
toTimeString(getUTCtime()) returns:
18:13:14 GMT+0000
And toUTCString(getUTCtime()):
Mon, 15 May 2006 18:13:14 UTC
So, on windows, these are ok, I think. At least they behave as I expected them
to. If I'm right with this, then toTimeString on linux is definitely wrong.
Now, toTimeString(UTCtoLocalTime(getUTCtime())) also returns:
18:13:14 GMT+0000
So, unless toTimeString always prints UTC time (which I don't think it should),
this is obviously wrong, and the problem has to be in the timezone conversion.
Part of the solution might be here:
http://www.digitalmars.com/drn-bin/wwwnews?D/20470, but if
GetTimeZoneInformation() fails, what if instead you use GetLocalTime() to get
the local time, and since getUTCtime() is ok, then you could use those two
values to get the timezone (UTCtime - localtime). Does that make sense?
-- Finally....
It's easy, in fact, for you to test it too: change your timezone to different
parts of the world when debugging this and see what happens. It's really easy to
do in both linux and windows.
Sorry if that sounded harsh, but I think right now std.date doesn't work in a
usable way outside your own timezone and maybe a couple more, and that is a
shame for D, especially since these problems have been around for so long.
--
Carlos Santander Bernal
More information about the Digitalmars-d-bugs
mailing list