> On my Debian box (using debian packaged Mono) everything is fine.
> 
> fog@ania:~$ csharp
> Mono C# Shell, type "help;" for help
> Enter statements below.
> csharp> Console.WriteLine("{0}", DateTime.Now);
> 12/10/2011 14:18:58
> csharp>
> 
> fog@ania:~$ date
> Wed Oct 12 14:19:04 CEST 2011
> 
> Can you show us your env?
> 
> federico
> 
> > user@server:~# date
> > Wed Oct 12 14:09:10 FET 2011
> 
> FET? This is an interesting time zone:
> http://en.wikipedia.org/wiki/Further-eastern_European_Time
> 
> It seems that Mono is thinking that you're now on EET
> (Eastern Europe Time, UTC+2), your former time zone.
> 
> Either you don't have correct time zone files or there is
> a bug in Mono's GetTimeZoneData.
> 
> Unlike other apps that only show the current time, Mono
> needs valid time probes for the whole year, so you can
> have invalid time zone info even if other apps seems to work.
> 
> Maybe it helps when I tell you that on 2012/01/01 the bug will
> vanish on its own :)
> 
> Robert


Hello guys, thanks for your replies. I think, I've understand the situation. 
Some weeks ago, Ukraine and Belarus has timezone changes by law, and now we 
are FET timezone (GMT+3, without DST). As Robert pointed, I've look into 
TimeZone.* methods, and their native implementations, and found, that wrong 
GMT offset brings by glibc's mktime function. But, it is not mktime bug 
(however, I'm not sure), it is mono issue - code from icall.c:5931:

    memset (&start, 0, sizeof (start));

    start.tm_mday = 1;
    start.tm_year = year-1900;

    t = mktime (&start);

I've found, that setting only tm_year in start struct is insufficiently. At 
least tm_mon must be set too, to avoid this issue. Simple test:

#include <stdio.h>
#include <time.h>
#include <memory.h>

int main(int argc, char *argv[])
{
    struct tm t;
    memset(&t, 0, sizeof(t));
    t.tm_year = 111; // 2011
    t.tm_mon = 10;   // wrong tm_gmtoff will received if comment out this line
    mktime (&t);
    printf("2011: %d\n", t.tm_gmtoff);

    return 0;
}

this is 100% reproducible inaccuracy for FET timezone, on all my accessible 
machines: 
* Debian Squeeze + mono 2.6.7 up to date
* Ubuntu 11.10 + mono 2.10.5 up to date
* Arch Linux + mono 2.10.5 up to date

on one machine, with Ubuntu 11.04, which is not updated last weeks, and stay 
on EEST timezone - all works fine.

I'm vote for setting month value to "start" struct - today it happen with FET, 
tomorrow it can be happen with any other timezone - world is changing all the  
time...

Also, thanks God, I'm saving all times as UTC+0 in my server databases ;)
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to