Bug 225 - Clock application gets time wrong in Berlin timezone.
: Clock application gets time wrong in Berlin timezone.
Status: RESOLVED WORKSFORME
Product: Desktop Widgets
Clock
: 2.1
: All Maemo
: Medium normal (vote)
: ---
Assigned To: unassigned
: clock-applet-bugs
:
: enhancement-it2005, ITOS2007HE-garage...
:
:
  Show dependency tree
 
Reported: 2005-11-07 01:18 UTC by Simon Budig
Modified: 2008-09-02 12:36 UTC (History)
4 users (show)

See Also:


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description Simon Budig (reporter) 2005-11-07 01:18:41 UTC
For some reason the clock application displays a time that differs from the
time
displayed in the clock home applet - the clock application is one hour ahead:

date in the shell returns 00:12, which is consistent with the time as displayed
in the clock home applet and consistent with my own clock statusbar applet (see
http://www.home.unix-ag.org/simon/files/n770/panelclock_0.1_arm.deb )

The clock application however shows 01:12.

The locale is de_DE, the timezone configured is Berlin (Germany), no daylight
saving time.
Comment 1 Simon Budig (reporter) 2005-11-07 22:50:39 UTC
Ok, some additional remarks:

After playing with the timezone (actually this might have been the first time
after flashing the device and restoring the backup, not sure) both clocks are
synchronous again. So maybe the backup restores the timezone information
incompletely?

However, now my own clock applet displays the wrong time. It essentially does 
  t = time (NULL);
  localtime_r (&t, &time_info);

and currently this seems to yield GMT.

It is perfectly possible that I miss something obvious here, if you have any
insight I'd appreciate hints.
Comment 2 Simon Budig (reporter) 2005-11-08 23:05:20 UTC
More remarks.

The code I pasted below gives the correct time on the commandline on the device.
However, the equivalent code yields GMT in my own statusbar applet. So *maybe*
the environment within the desktop application is running with a wrong timezone.
I don't understand why the stock desktop clock yields the correct time though.

Does the timezone get set *after* the desktop application got started?

#include <sys/time.h>
#include <time.h>
#include <stdio.h>

int main (int argc, char *argv[])
{
  struct timeval  tv;
  struct tm      *time_info;

  gettimeofday (&tv, NULL);
  time_info = localtime (&tv.tv_sec);

  printf ("%d:%d\n", time_info->tm_hour, time_info->tm_min);

  return 0;
}
Comment 3 Simon Budig (reporter) 2005-11-09 00:22:05 UTC
Some more remarks...

The Desktop application is messing around with the TZ environment variable. If I
unset() it before determining the time everything works correctly. It seems
there is some mechanism that sets the TZ variable when changing the timezone in
the clock application. Not sure what wents wrong there.

Generally I'd recommend to unset TZ always, this then picks up the system default.

(however, after persisting in unsetting the TZ variable in my clock statusbar
applet the clock application sometimes seems to crash sometimes on setting the
timezone - maybe there is code that relies on a non-NULL TZ environment variable?)
Comment 4 Simon Budig (reporter) 2005-11-09 00:45:52 UTC
Ah sorry, I mean unsetenv().

Please note that unsetenv("TZ") is different from setting TZ to an empty value,
the latter seems to be interpreted as GMT-Timezone.
Comment 5 Simon Budig (reporter) 2005-12-11 18:59:57 UTC
Debugging without source code is so much fun...

Something sets the TZ environment variable to values like "8#\x14A" where the
\x14 really is chr (14). That is simply bogus - TZ should be unset so that the
date related functions pick up the timezone configured for the system.
If TZ has to be set (frankly, I don't see a need for that) it should contain
values as described in "man tzset".

After disabling some of the plugins via chmod and checking the value of the
variable, I am pretty confident that the guilty party is the libtn_mail_plugin
for the hildon-navigator. It seems that having this one enabled results in the
broken TZ value.

Please fix this.
Comment 6 Simon Budig (reporter) 2005-12-11 19:03:08 UTC
Reassigning to the Desktop component, since the wrong TZ value is inside the
desktop application.
Comment 7 Simon Budig (reporter) 2005-12-11 20:45:44 UTC
Seems the RSS plugin fiddles with TZ as well.
Comment 8 David Hagood 2006-04-21 19:13:24 UTC
I found that all timezone files in /usr/share/zoneinfo are missing, save
Europe/Helsinki.

Putting the missing files for the US in, and then setting the /etc/localtime
link seems to correct the desktop clock, but not the clocks shown for the "home
city" and "destination city".

I *also* cannot set the "Daylight savings zone" field - has it been deprecated
in favor of actually using the zoneinfo?
Comment 9 Maemo QA (deprecated) 2006-04-25 16:07:16 UTC
*** Bug 457 has been marked as a duplicate of this bug. ***
Comment 10 Maemo QA (deprecated) 2006-04-25 16:07:51 UTC
Still an issue with the latest product image.
Comment 11 Maemo QA (deprecated) 2006-04-25 16:16:41 UTC
Claiming ownership. Bug has been reported to upstream maintainer.
Comment 12 Maemo QA (deprecated) 2006-05-23 10:34:00 UTC
Feature request has been forwarded to upstream maintainer.
Comment 13 Simon Budig (reporter) 2006-07-28 22:39:00 UTC
This is not an "enhancement" request, the messing with the TZ environment
variable breaks all third party applets that run inside the desktop application.

I have this workaround that works reasonably well, but of course is ugly as
hell. This really should be fixed and I am kind of disappointed by the current
response, given the amount of time I have invested to track this down (and note
that I cannot track this down further, since the newsreader and mail applet are
not open source).

  tz_str = g_strdup (g_getenv ("TZ"));
  g_unsetenv ("TZ");  
  
  gettimeofday (&tv, NULL);
  time_info = localtime (&tv.tv_sec);

  if (tz_str)
    {
      g_setenv ("TZ", tz_str, FALSE);
      g_free (tz_str);
    }
Comment 15 Andre Klapper maemo.org 2008-06-03 14:07:25 UTC
Simon, is this still an issue on the N800 or N810?

[in reply to comment #11]
>  Bug has been reported to upstream maintainer.
could not find an upstream ticket.
Comment 16 Simon Budig (reporter) 2008-06-03 14:40:27 UTC
It might be fixed - I did not witness this behaviour for a while now. But maybe
I should add the debugging code back to the clock applet again.
Comment 17 Quim Gil nokia 2008-09-02 08:40:34 UTC
Can we resolve this bug now, and reopen if the issue happens to be found still
valid by some other user?
Comment 18 Simon Budig (reporter) 2008-09-02 12:36:42 UTC
Yeah. Doing so.