digitalmars.D.learn - timezone problem
- Qian Xu (10/10) Jan 13 2009 Hi All,
- Qian Xu (1/1) Jan 13 2009 BTW: Is there any Date.Format("YYYY-mm-dd") function?
- Stewart Gordon (4/5) Jan 13 2009 Not in Phobos. But there is such a thing in my utility library:
- Sergey Gromov (3/17) Jan 13 2009 I thought that std.date.getUTCtime(), std.date.UTCtoLocalTime() and
- Stewart Gordon (12/14) Jan 13 2009 std.date is somewhat badly designed - a time can be in any time zone but...
- Qian Xu (6/12) Jan 14 2009 Thanks Stewart, this is a great library.
- Kagamin (3/10) Jan 14 2009 Even windows doesn't have this kind of heuristics. The only solution is ...
- Stewart Gordon (9/14) Jan 14 2009 That's the best thing indeed for timestamps and the like. For some
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
Jan 13 2009
BTW: Is there any Date.Format("YYYY-mm-dd") function?
Jan 13 2009
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.
Jan 13 2009
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 ^^) --QianI thought that std.date.getUTCtime(), std.date.UTCtoLocalTime() and std.date.LocalTimetoUTC() were quite enough.
Jan 13 2009
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.
Jan 13 2009
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
Jan 14 2009
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
Jan 14 2009
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.aspxThe 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.
Jan 14 2009