[Top][All Lists]

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

Re: [DotGNU]DateTime.Now is WRONG :)

From: David Logan
Subject: Re: [DotGNU]DateTime.Now is WRONG :)
Date: Wed, 30 Jun 2004 22:00:50 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040316

David Logan wrote:

Hey guys, anyone know how come the DateTime class Now property returns the wrong time?

David Logan

address@hidden temp]$ cscc -o tt.exe tt.cs
address@hidden temp]$ ilrun tt.exe;date
6/30/04 10:37:46 PM -5
Wed Jun 30 21:37:47 MDT 2004
address@hidden temp]$ cat tt.cs
class Test
  static void Main()
address@hidden temp]$
Developers mailing list

Looking at the problem, it is in pnet/support/time.c in function ILGetTimeZoneAdjust. As shown below, it calls localtime(), and then modifies the returned timezone offset hours by one hour if the "isdst" variable is set. In my case, I my timezone is GMT-7. The returned timezone from the call is "GMT-6" and isdst=1. So this function modifies it by another hour and returns GMT-5.

The documentation for localtime and the tm struct is unclear. It seems that isdst=1 means that the returned timezone has already been modified for daylight savings. Is this correct? Should I inquire on the Unix newsgroup?

David Logan

ILInt32 ILGetTimeZoneAdjust(void)
#if !defined(__palmos__)
       static int initialized = 0;
       static int isdst = 0;
   static long timezone = 0;
/* Call "localtime", which will set the global "timezone" for us */
               time_t temp = time(0);
               struct tm *tms = localtime(&temp);
               isdst = tms->tm_isdst;
               timezone = -(tms->tm_gmtoff);
               initialized = 1;
       return (ILInt32)(timezone - (isdst ? 3600 : 0));
       /* TODO */
       return 0;

reply via email to

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