dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] timezone issues in pnet and ms.net


From: Carl-Adam Brengesjo
Subject: [Pnet-developers] timezone issues in pnet and ms.net
Date: Thu, 07 Oct 2004 07:24:26 +0200
User-agent: Mozilla Thunderbird 0.8 (Windows/20040913)

Cheers,

For those who don't know... I'm from Sweden; so right now the timezone here is CEST (+0200), normally it's CET (+0100). So if the time here is 05:57 (24 hour format), the GMT/UTC time is 03:57.

But the timezone offset seems a bit off in pnet -- and in Microsoft's .NET. That's why I'm not sure this is a bug, or just *a deliberate incorrect behaviour to keep compat*.

I've made the following test:

test.cs:
using System;
class Test
{
 static void Main(String[] args)
 {
  String format = args.Length > 0 ? args[0] : "r";
  Console.WriteLine(DateTime.Now.ToString(format));
 }
};

On my linux box:
$ cscc -o test.exe -g test.cs -lSystem
$ ilrun test.exe
Thu, 07 Oct 2004 06:09:51 GMT
$ ilrun test.exe zzzz
+02:00
$ date
Thu Oct  7 06:09:57 CEST 2004
$ date -u
Thu Oct  7 04:10:00 UTC 2004

On windows (using cygwin):
$ ilrun test.exe
Thu, 07 Oct 2004 05:09:03 GMT
$ ilrun test.exe zzzz
+01:00
$ date
Thu Oct  7 06:09:08 WEDT 2004
$ date -u
Thu Oct  7 04:09:12 UTC 2004

On same windows box:
C:\> csc test.cs
Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.

C:\> test.exe
Thu, 07 Oct 2004 06:09:16 GMT
C:\> test.exe zzzz
+02:00
C:\> date /T && time /T
2004-10-07
06:09

Both machines are configured to CET with daylight saving -- CEST.

(note that the time differs somewhat due to the time it takes to type + change terminal etc and that they aren't synced)

What can clearly be determined by above test is:
1) pnet on cygwin belives GMT is +0100
2) pnet on linux belives GMT is +0200
3) .net belives GMT is +0200

If you didn't already know, GMT is +0000.

I have breifly looked into the problem and noticed that pnet formats r/R
(supposed to be RFC1123) with "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'", meaning GMT is just appended to the current time in the current timezone, no matter what timezone you're in. I assume this is the behaviour of .NET aswell (from what I can tell from the SDK).

Either change the RFC1123 format string and have datetime parse a format which would either print the correct timezone name/offset (using offsets is recommended by RFC1123). Or have all RFC1123 formatted strings be printed in UTC time... making the beahviour of just append "GMT" legimit.
I strongly recommend the former (or a simlar) solution :)

But I cannot explain why pnet on cygwin says the UTC offset is +0100 when it should be +0200. However, my guess is that it's b/c Windows always treats the hardwareclock as localtime while linux defaults to UTC time, so pnet belives that the hardware clock is UTC time, while it really is just the daylight saving time.

As the date and time is specific to each computer, I'd like some comments on this by people with other timezone configurations before filing any bugs.

By the way, "zzzz" is *NOT* RFC1123 compilant. "zzzz" outputs timezone difference as "(+|-)HH:mm", while it should be "(+|-)HHmm". I know that this is the way Microsoft have done, but I just want you too keep this is mind when considering an alternative RFC1123 format string for pnet. And as I said before, there's no format string for a RFC1123 formatted date :( RFC1123 dates are same as RFC822, with the exception of using 4 digit year numbers instead of 2 digits (2004 vs 04) and some corrections.


/ ptha



reply via email to

[Prev in Thread] Current Thread [Next in Thread]