Help - Search - Members - Calendar
Full Version: Datentime Enhancement
OESF Forums > Distros, Development, and Model Specific Forums > Distro Support and Discussion > pdaXrom
Meanie
I have enhanced the datentime python script which is used to set the date and time to also allow you to set the timezone. I have added an additional third tab which has just a simple dropdown list of 24 timezones, one city for each of the major time lines off GMT. This makes it simple if your city is part of the pick list to set your timezone. If it isn't, you need to set it manually by symlinking your timezone from /usr/share/zoneinfo to /etc/localtime.
Of course you need to actually install the timezones package first in order to be able to select a timezone.
I also have updated the timezones package (timezones_2007_all.ipk) to include the latest daylight savings data.
InSearchOf
We will add this to the builder...
HoloVector
Very nice. Thank you.
Meanie
I actualy dont know how to program in python and just hacked it together so someone who knows python can probably do a better job and like add a file selector box to browse the zoneinfo directory to pick and select from all the available timezone data, and of course make the dropbox, etc.. look a bit nicer smile.gif
daniel3000
QUOTE(Meanie @ Mar 12 2007, 04:31 PM)
I actualy dont know how to program in python and just hacked it together so someone who knows python can probably do a better job and like add a file selector box to browse the zoneinfo directory to pick and select from all the available timezone data, and of course make the dropbox, etc.. look a bit nicer smile.gif
*


Hi Meanie,

if you want to include more than these 24 main cities in the timezones:

You can use a file selector instead of a dropdown list. That's what I have done using a shell script with XDialog using the file selection dialog which is pointed to the zoneinfo directory. The user can select his timezone directly from the tree of timezone files in /usr/share/zoneinfo (which is quite intuitive IMHO).
Then the script links the returned file name to /etc/localtime.

No idea how to embed that into the datentime.py, though biggrin.gif

daniel
Meanie
QUOTE(daniel3000 @ Mar 13 2007, 12:56 AM)
QUOTE(Meanie @ Mar 12 2007, 04:31 PM)
I actualy dont know how to program in python and just hacked it together so someone who knows python can probably do a better job and like add a file selector box to browse the zoneinfo directory to pick and select from all the available timezone data, and of course make the dropbox, etc.. look a bit nicer smile.gif
*


Hi Meanie,

if you want to include more than these 24 main cities in the timezones:

You can use a file selector instead of a dropdown list. That's what I have done using a shell script with XDialog using the file selection dialog which is pointed to the zoneinfo directory. The user can select his timezone directly from the tree of timezone files in /usr/share/zoneinfo (which is quite intuitive IMHO).
Then the script links the returned file name to /etc/localtime.

No idea how to embed that into the datentime.py, though biggrin.gif

daniel
*



python has filesel which can be used for just that, but i was too lazy to learn python and do it properly because the dropdown includes Sydney, Tokyo, Singapore, Taipei and Bangkok which are places I go to and they all are already there smile.gif
Laze
Great work based on my old crappy code - I still hate the fact that we made anything in python. One day we might get all the apps to be native c.
Jon_J
Fresh flash of pdaxii13-akita5.3.2 last night on my C3200
My time settings don't "stick". I just rebooted for an unrelated reason and my clock went back 6 hours.
I selected "GMT -6 Saskatchewan" and the clock is still 6 hours behind.
I Live in the same timezone as Chicago, and it is also GMT -6
Do I need to manually link this to make it keep time after a reboot?

EDIT:
I set my clock to the correct time in the datentime app, then rebooted again.
It goes back 6 hours just like my first reboot.
Jon_J
I renamed /etc/localtime to localtime_old
Then I symlinked my timezone to /ect/localtime

ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime

This created a new /etc/localtime link (I checked it, and it is linked to Chicago)
I rebooted, and my clock still looses 6 hours.
How can I make the clock "remember" the correct time for where I live?
T3_slider
Well, I'm no expert, but rebooting might be resetting the hardware clock (well, from what I understand there is no real hardware clock, but there is a figurative one that still accepts commands). After setting the correct time in the datentime app, in a terminal execute
CODE
/sbin/hwclock --systohc

(You don't really need the /sbin/ since pdaXrom runs as root, so you could just type hwclock --systohc, but in case you have a wonky setup that doesn't run as root the first command should always work).

Or if you want to keep your figurative hardware clock in UTC (this never works for me, it always goes to local time even on my Slackware box), you can type
CODE
/sbin/hwclock --systohc --utc
instead.

If this doesn't work someone more intelligent will need to help you out. wink.gif
Jon_J
Thanks T3_slider for the tips.
On the previous install of pdaxii13-akita5.3, the clock didn't do this.
It always remembered the time when rebooting.
This situation was introduced (I think) by the new version of pdaxii13-akita5.3.2
T3_slider
Jon_J, does the "hwclock --systohc" actually fix the problem or not (if so then it would just be a matter of adding the command to the datentime app I think -- if not there are bigger problems).
Jon_J
no, that didn't do anything that I can tell, the clock still resets after rebooting. I was going to wait for meanie, he modified the datentime file, so maybe he will know what is going on.
Meanie
the default timezone, ie none will be around GMT 0, so after you set your timezone, the internal clock will readjust your time using the current time plus the timezone you are in. This means you will be a few hours ahead or behind and need to then set your time again for you timezone and reboot.
Jon_J
QUOTE(Meanie @ Mar 13 2007, 08:10 PM)
the default timezone, ie none will be around GMT 0, so after you set your timezone, the internal clock will readjust your time using the current time plus the timezone you are in. This means you will be a few hours ahead or behind and need to then set your time again for you timezone and reboot.
*

I'm not following you meanie, sorry.
you said to set your time zone.
I do this.
Then you say to set the time.
I would do this, but my time remained the same after I set my timezone. Should I just close and reopen datentime and click [OK]?
This is what I did, I closed and reopened datentime and just clicked [OK]
Now I'm rebooting...
After rebooting, the time lost 6 hours, again.
EDIT:
Doesn't anyone else with pdaxii13-akita5.3.2 have this problem??

I also tried setting the timezone, then just closing datentime and rebooting, but this method loses 6 hours also.
When I set the timezone, nothing changes with the clock.
Jon_J
OK, I did this again, but this time I selected London 0 GMT
now the clock on the taskbar and the clock in datentime are showing as different (6 hours difference)
When I reboot, my time is correct. smile.gif
Now I don't have to re-set my clock after each reboot.

But, I don't live in London, I live near Chicago or in the -6 GMT timezone (Saskatchewan)

EDIT: I tried this several times.
I set the zone to London 0 GMT, set the time, rebooted. the clock stayed correct to my time.
Then I set the zone to Saskatchewan -6 GMT, set the clock, and rebooted, the time is off by -6 hours again.
So I tried this again several times and I cannot get my clock to stay at correct time.
The only zone that works for me is London -0 GMT
EDIT2:
I just remembered I do have a modified mb-applet-clock made by daniel3000
http://www.oesf.org/forums/index.php?showt...ndpost&p=153012
It allows you to set options in ~/.matchbox/mbdock.session
I have mine set so it shows AM and PM like this:
mb-applet-clock -m -p 8
-m makes it show AM and PM
-p 8 makes the clock display smaller

Maybe this is what is causing me all my problems with time zones as I have posted about here and tryannozaurus.
I might need to remove those settings and go back to the old mb-applet-clock
It's hard for me to read a 24 hour clock, I always have to subtract 12 from anything higher than 13 O-clock.
Antikx
I noticed my time was wrong after a resume today.
This time I stopped atd, ran ntpdate, restarted atd and so far so good.
I haven't tried rebooting yet.
EDIT: I just rebooted and it looks like I need to reset the time.
I should add that I haven't flashed to the latest and greatest yet. I'm one version behind now.
Jon_J
my clock is fine if I don't reboot, but meanie mentions it is good to reboot pdaxii13 after installing/uninstalling stuff because it checks your disk and some other things on reboot and cleans up some other things. Can you tell I'm not too good at Linux terminology?
Antikx
smile.gif
You're doing great man, don't worry about it.
I understand what you mean.
Meanie
there was a problem with the way the datentime script worked. it assumes there is no timezones, only local time = gmt 0, but i hacked that smile.gif
daniel3000
QUOTE(Laze @ Mar 12 2007, 10:20 PM)
Great work based on my old crappy code - I still hate the fact that we made anything in python. One day we might get all the apps to be native c.
*


Hi Laze,

I must say, it's not that bad than these tools are written in Python.
That way, it is relatively easy, even without much Python knowledge, to modify them slightly.

daniel
Jon_J
The new datentime isn't working for me as I thought, I posted about this in the pdaxii13 thread for the spitz version.
http://www.oesf.org/forums/index.php?showt...ndpost&p=156323
I installed meanie's new datentime_1.0.8_armv5tel.ipk
Yesterday, I set the zone, then set the time, then rebooted.
I did the above twice, and my time remained correct.
This morning (next day) I rebooted and my panel clock lost 6 hours (again) just like it was doing several days ago.
I'm not sure what is going wrong, in the meantime, I'll have to resort to using London's timezone. (-0 GMT)
EDIT:
I just set the timezone to London and the clock inside datentime changed to my correct time, but the clock on the panel is off by -6 hours.
Whenever I would set the zone for my area, as previously, the clock in datntime would NOT move, and the panel clock would match the clock inside datentime.
Notice the 2 different actions?
1. Setting the zone to -0 GMT moves the clock in datentime
2. Setting the zone to -6 GMT does NOT move the clock in datentime. (It doesn't matter if the clock is actually correct or not, it doesn't move like in first example)
Antikx
Sorry if you've tried this already, but have you tried not using the gui, and deleting /etc/localtime then recreating the symlink?
Jon_J
I did the below before I installed the new datentime ipk
I renamed the /etc/localtime symlink, then created a new one that points to /usr/share/zoneinfo/America/Chicago
I had the same problem as always. Doing that didn't help, I was still loosing 6 hours when I rebooted.
Jon_J
I may have found a problem, but I don't know the exact solution.
When I use the datentime GUI and set my zone to London, and look at the properties of this symlink /ect/localtime, it says it's linked to /usr/share/zoneinfo/London
When I use the datentime GUI and set my zone to Saskatchewan (which is -6 GMT) and I check the properties of the symlink /ect/localtime, it says it's linked to /usr/share/zoneinfo/MST7MDT
Where did Saskatchewan go, isn't it supposed to be linked to Saskatchewan??
EDITED out typing errors
Antikx
I was born and raised in Saskatchewan and I must finally admit that we are part of a world-wide time chaos conspiracy project. smile.gif
In all seriousness I think that is the code for Sask time.
http://www.google.ca/search?hl=en&q=%2BMST...nG=Search&meta=
Jon_J
I just have to accept that using London -0 GMT is my only choice, otherwise I'll have to reset my clock after each reboot.
Antikx
QUOTE(Jon_J @ Mar 15 2007, 04:11 PM)
I just have to accept that using London -0 GMT is my only choice, otherwise I'll have to reset my clock after each reboot.
*

I've been resetting my time after a reboot since I first started using pdaXrom so I guess it doesn't bother me too much.
I forget, when using Cacko, does it keep the time after a reboot?
Jon_J
yes Cacko and sharp do keep time on reboot.
pdaxii13 is supposed to keep the time the same after reboot, but for some reason mine doesn't.
I do have a modified mb-applet-clock that uses changeable settings from ~/.matchbox/mbdock.session
It's in this post. http://www.oesf.org/forums/index.php?showt...12&#entry153012
Meanie
my date/time is remembered most the time after reboot unless it locks up and you have to reset it.

but how often do you actually need to reboot your Z? once a month? I just suspend/resume and it is so much more responsive after I fixed the multiple rotations from executing after a resume...

actually, make sure you do have the latest datentime.py file. installing a new package without removing the older version sometimes does not work. even though it tells you that you got the new package installed, you still have the old files...

when you run datentime.py from a terminal, you should see the date and time printed twice, once in GMT0 and once in your timezone...
Jon_J
running datentime.py in a terminal just launched the GUI.
There was nothing printed or shown in the terminal.
I'm pretty sure I uninstalled the previous version first before installing the last one. I'll try uninstalling my current one, and installing the latest one.
QUOTE(Meanie @ Mar 15 2007, 09:30 PM)
my date/time is remembered most the time after reboot unless it locks up and you have to reset it.

but how often do you actually need to reboot your Z? once a month? I just suspend/resume and it is so much more responsive after I fixed the multiple rotations from executing after a resume...

actually, make sure you do have the latest datentime.py file. installing a new package without removing the older version sometimes does not work. even though it tells you that you got the new package installed, you still have the old files...

when you run datentime.py from a terminal, you should see the date and time printed twice, once in GMT0 and once in your timezone...
*
Jon_J
I uninstalled my current datentime.
I checked the /usr/bin directory, and made sure "datentime.py" was removed, and it was.
Then I re-installed datentime_1.0.8_armv5tel.ipk
I had to set the zone and clock and reboot twice, to make my time display correctly.
On the first reboot, it lost -6 hours, setting the clock again and rebooting resulted in a correct clock display.
I'm not sure if this will stay this way, since I haven't rebooted again.
Oh BTW, I can tell if the clock is going to "hold it's correct value" when rebooting.
Once I exit 'X' and type in reboot, there is a line that displays the time.
EDIT:
meanie, on your website you say one should reboot after installing/uninstalling a lot of pkgs.
I have been trying out a lot of pkgs, and this is the reason I reboot more that once a month.
HoloVector
Jon_J, I am having the exact same problem as you on my recently flashed and upgraded to full 3200. Thanks to some resume issues I have rebooted for the 4th time today.

Meanie, why was Saskatchewan chosen as the GMT -6 zone aka Central Standard Time? The province of Saskatchewan does not observe daylight savings time and therefore spends half of it's year on the same time as the CST (GMT -6) and the other half in synch with MST (GMT -7). That means that even if it was keeping time properly it will get out of sync for the CST folks (Manitoba, Illnois, etc) after some time changes.

Meanie, would it be possible to replace the city names for the Americas with the timezone names in the drop down list instead? The Timezones are: Maritime, Eastern, Central, Saskatchewan, Mountain and Pacific. Thanks for all your hardwork, Meanie.
Meanie
ok, this version of datentime will keep the right time even after several reboots.
also fixed the timezones (i think) for the northern americans.
Meanie
daylight savings has just ended here in Sydney (AET) and my Z automatically turned the clock back by an hour! yay smile.gif

this was using the updated zoneinfo data from the updated timezones package and linking /etc/localtime to my corresponding timezone using the updated datentime python script.
HoloVector
Thanks Meanie. I going to try this after I ipkg upgrade my 3200 to the latest pdaxii13.
zeigerpuppy
I am also getting the time shifting problem whenever I suspend or reboot, however it goes 10 hours forward for me (Melbourne time).
My suspend script contains the following:

suspend() {
# stop atd (but only if it's running)
if [ -n "$(ps | grep atd | grep -v grep)" ]; then
/etc/rc.d/init.d/atd stop
fi
hwclock --systohc
return 0
}

resume() {
# start atd (but only if service installed and enabled)
if [ -x /etc/rc.d/init.d/atd ]; then
/etc/rc.d/init.d/atd start
fi
hwclock --hctosys
return 0
}
return 0



I also have a problem with the script:

# python /usr/bin/datentime.py
Traceback (most recent call last):
File "/usr/bin/datentime.py", line 2, in ?
import gtk
File "/usr/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line 81, in ?
_init()
File "/usr/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line 66, in _init
_gtk.init_check()
AttributeError: 'module' object has no attribute 'init_check'

I have rebooted to no avail and installed the latest gtk2
Meanie
QUOTE(zeigerpuppy @ Apr 10 2007, 11:33 PM)
I am also getting the time shifting problem whenever I suspend or reboot, however it goes 10 hours forward for me (Melbourne time).
My suspend script contains the following:

suspend() {
  # stop atd (but only if it's running)
  if [ -n "$(ps | grep atd | grep -v grep)" ]; then
  /etc/rc.d/init.d/atd stop
  fi
  hwclock --systohc
  return 0
}

resume() {
  # start atd (but only if service installed and enabled)
  if [ -x /etc/rc.d/init.d/atd ]; then
  /etc/rc.d/init.d/atd start
  fi
  hwclock --hctosys
return 0

  return 0



I also have a problem with the script:

# python /usr/bin/datentime.py
Traceback (most recent call last):
  File "/usr/bin/datentime.py", line 2, in ?
    import gtk
  File "/usr/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line 81, in ?
    _init()
  File "/usr/lib/python2.4/site-packages/gtk-2.0/gtk/__init__.py", line 66, in _init
    _gtk.init_check()
AttributeError: 'module' object has no attribute 'init_check'

I have rebooted to no avail and installed the latest gtk2
*


you are probably missing pygtk
zeigerpuppy
Thanks Meanie,

that worked but I still have the problem with the time shifting (back to GMT 0) when I suspen/resume,

is there a problem with my suspend/resume scripts?

EDIT
I found the error, it was in the resume script, it was running hwclock after starting the atd daemon, not before... updated version below

resume() {
# start atd (but only if service installed and enabled)
hwclock --hctosys
if [ -x /etc/rc.d/init.d/atd ]; then
/etc/rc.d/init.d/atd start
fi
return 0

I know this is rather off topic... but is there a way to start a ppp connection automatically on resume so that ntpdate can also be run automatically?
EDIT
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.