Re: gtk-tutorial: calendar demo broken?



Caspar Bothmer wrote:
> 
> Hello,
> 
> did anybody try the calendar demo from the tutorial? I compiled and run
> it and it works fine except that it prints out the wrong date, always
> one day after - I mark the 20th of a given month and it prints "Signal:
> day_selected 19.12.2001". It isn't influenced by the "WEEK_START_MONDAY"
> flag.

Ok, I tracked down the problem:

The correct date "Dec, 20 2001" is set to date "Dec, 20 2001 00:00:00".
This yields "Dec, 19 2001 23:00:00 UTC" and therefore shows up a wrong
date - "Dec, 19 2001".

Replacing gmtime with localtime in the demo code gives the correct
result on my machine. The patch is attached.


bye

caspar

-- 
Public-Key-Server: z.B. http://blackhole.pca.dfn.de
Caspar Bothmer <caspar cbothmer org> ID: 0xCE9DDE57
FP: 8D3B 7211 6F0C D52C 7226  F060 9182 97EC CE9D DE57
--- calendar.c	Thu Dec 13 01:36:11 2001
+++ calendar.c.old	Thu Dec 13 01:33:33 2001
@@ -64,7 +64,7 @@
 			 &tm.tm_year, &tm.tm_mon, &tm.tm_mday);
   tm.tm_year -= TM_YEAR_BASE;
   time = mktime(&tm);
-  strftime (buffer, buff_len-1, "%x", localtime(&time));
+  strftime (buffer, buff_len-1, "%x", gmtime(&time));
 }
 
 void calendar_set_signal_strings( char         *sig_str,


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