Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
January 13, 2009 timezone problem | ||||
---|---|---|---|---|
| ||||
Hi All, I am fighting with date time conversion and have a problem right now: I want to convert a local timestamp to UTC timestamp. So I have to get the time zone information. However in some countries (ie. German, US), the offset is not constant, because of daylight saving issue. Is there any "hidden" routine can tell the correct time zone information (cross platform, esp. open suse) Any hints are apprecated ^^) --Qian |
January 13, 2009 Re: timezone problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Qian Xu | BTW: Is there any Date.Format("YYYY-mm-dd") function? |
January 13, 2009 Re: timezone problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Qian Xu | Tue, 13 Jan 2009 11:27:40 +0100, Qian Xu wrote:
> Hi All,
>
> I am fighting with date time conversion and have a problem right now:
> I want to convert a local timestamp to UTC timestamp.
> So I have to get the time zone information.
> However in some countries (ie. German, US), the offset is not constant,
> because of daylight saving issue.
>
> Is there any "hidden" routine can tell the correct time zone information (cross platform, esp. open suse)
>
> Any hints are apprecated ^^)
>
> --Qian
I thought that std.date.getUTCtime(), std.date.UTCtoLocalTime() and
std.date.LocalTimetoUTC() were quite enough.
|
January 13, 2009 Re: timezone problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Qian Xu | Qian Xu wrote: > BTW: Is there any Date.Format("YYYY-mm-dd") function? Not in Phobos. But there is such a thing in my utility library: http://pr.stewartsplace.org.uk/d/sutil/ Stewart. |
January 13, 2009 Re: timezone problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sergey Gromov | Sergey Gromov wrote: <snip> > I thought that std.date.getUTCtime(), std.date.UTCtoLocalTime() and > std.date.LocalTimetoUTC() were quite enough. std.date is somewhat badly designed - a time can be in any time zone but has no time zone information in it. And toString(d_time) expects a UTC time but formats in the user's time zone. My library stores all times in UTC, but allows them to be manipulated in any time zone. But it doesn't yet support daylight saving time adjustments. I haven't quite worked out how best to do this. (It initialises the working time zone to the user's current time zone under Windows, but that's it at the moment.) http://pr.stewartsplace.org.uk/d/sutil/ Stewart. |
January 14, 2009 Re: timezone problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | Stewart Gordon wrote:
> My library stores all times in UTC, but allows them to be manipulated in any time zone. But it doesn't yet support daylight saving time adjustments. I haven't quite worked out how best to do this. (It initialises the working time zone to the user's current time zone under Windows, but that's it at the moment.)
>
Thanks Stewart, this is a great library.
However the daylight saving problem is a big issue. I think it would be
easier to use an external library from other programming language (ie.
PHP), instead of implementing the own one for D. (But I do not know how)
--Qian
|
January 14, 2009 Re: timezone problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Qian Xu | Qian Xu Wrote: > Hi All, > > I am fighting with date time conversion and have a problem right now: > I want to convert a local timestamp to UTC timestamp. > So I have to get the time zone information. > However in some countries (ie. German, US), the offset is not constant, > because of daylight saving issue. Even windows doesn't have this kind of heuristics. The only solution is to keep all timestamps in UTC and leave local time representation only for user eyes and don't care about its precision. See also http://www.codeproject.com/KB/datetime/dstbugs.aspx |
January 15, 2009 Re: timezone problem | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | Kagamin wrote: <snip> > Even windows doesn't have this kind of heuristics. The only solution > is to keep all timestamps in UTC and leave local time representation > only for user eyes and don't care about its precision. That's the best thing indeed for timestamps and the like. For some other kinds of applications, different methodologies'll be needed. > See also > http://www.codeproject.com/KB/datetime/dstbugs.aspx The bugs pertaining to that page are probably as bad as the bug it tries to describe. But I wonder: Is there any sensible way that M$ could eventually paint itself out of this corner? Stewart. |
Copyright © 1999-2021 by the D Language Foundation