Time and date initialization
-
@Frederic-Baumann The default timezone is
UTC
, did you set it through the console ever?
-
@Frederic-Baumann FYI: I am located in Auckland, New Zealand.
- I have my time zone set in Console->Settings->General Settings->Timezone to (GMT+12:00) Auckland, Wellington
- My /etc/TZ file contains: NZST-12NZDT,M9.5.0,M4.1.0/3
- My /etc/config/system contains the following relevant entries:
- option zonename '(GMT+12:00) Auckland, Wellington'
- option timezone 'NZST-12NZDT,M9.5.0,M4.1.0/3'
All as expected.
- Console->Settings->General Settings->Timezone uses code in /www/apps/onion-settings/onion-settings-general.html, in particular the data in var timezones
-
Can't remember what I did regarding time settings when I unpacked the Omega.
UTC by default is fine, so when my project is advanced enough I will factory-reset my Omega and see who to pack things properly with this.
Thank you both again
-
While browsing the files on the Onion, I wonder if there is not a bug on setting the "zonename" (as opposed to "timezone"):
-
when I change the timezone through the console, the /etc/config/system still indicates "UTC" as zonename
-
in /www/apps/services/onion-device-provider/onion-device-provider.html, line 202, the zonenamePromise seems to change the timezone, instead of the timezone. Actually it looks like the timezone is changed twice, instead of changing the timezone and the zonename. Which would explain the zonename sticks to UTC even though the timezone is changed.
Looks like the problem does not happen on Kit's Onion, maybe I have a too old build.
Hope this helps?
-
-
Now one question please.
[ things are going strange on my Omega: the /etc/TZ file is now present on my system, but the /etc/timezone one I was featuring a few days ago has disappared!!! Well, this is good news, since I am back to normal, but I don't understand what happened. ]
I am trying to change the timezone with the command line, by mimicking the console:
uci set system.@system[0].timezone=XYZ
uci commit systemThis changes the /etc/config/system file, but /etc/TZ is not changed (it is actually a link to /tmp/TZ, which does not change).
And finally the "date" command still features the previous timezone
So, what should I do on the command line to actually change the time zone?
Thanks in advance!
(btw, when I change the timezone through the console, all is changed properly)
-
Me again... I did investigate further, and could see that /etc/init.d/system was doing a "echo $timezone > /tmp/TZ" (and also a "date -k")
So am I correct by assuming that to properly change the timezone from command line, one should:
- uci set system.@system[0].timezone=XYZ
- uci commit system
- /etc/init.d/system reload
???
(indeed, I don't understand how and when /etc/init.d/system is called when the timezone is changed from the console - if I can get an explanation for that, that would be cherry on the cake)
Thanks!
-
@Frederic-Baumann I have done some playing with your suggestion of using:
- uci set system.@system[0].timezone=XYZ
- uci commit system
- /etc/init.d/system reload
and can confim that it actually works so long as the XYZ is an actual timezone code and that the setting is preserved over reboot.
In order to play nicely with the timezone setting in Console-->Settings could I suggest some small improvements:
- As well as doing uci set system.@system[0].timezone=XYZ also do a uci set system.@system[0].zonename="zone-description"
- The timezone XYZ and the zone-description should match the values that are listed in var timezones in file /www/apps/onion-settings/onion-settings-general.html
Regarding how and when /etc/init.d/system is normally called, there is a symbolic link to it from /etc/rc.d/S10system Any files in /etc/rc.d with a name like S<nn><xxxxx> are executed at start time in increasing order of <nn> value. They are called with a parameter of start, thus /etc/rc.d/S10system cause /etc/init.d/system start to be executed at start up time.
-
Thanks Kit for the tests and the init cycle demystification!
Indeed, I think the /etc/init.d/system script is also called when one changes the time zone (otherwise as I was saying earlier, the new time zone is not appearing in the date command). And I am wondering what is the magic behind this. Actually it looks like the console is written with some web framework, but I don't know which one, and I don't understand who it is architectured. Might look like Symfony, but it is not.
-
@Frederic-Baumann Have corrected one bit in my previous response - had a typo - have changed:
- As well as doing uci set system.@system[0].timezone=XYZ also do a uci set system.@system[0].timezone="zone-description""
to:
- As well as doing uci set system.@system[0].timezone=XYZ also do a uci set system.@system[0].zonename="zone-description"
Regarding what the Console is written in, while I know little about it, from some digging in the /www files on the Omega, I think it uses Polymer: https://www.polymer-project.org/1.0/ and https://github.com/Polymer/polymer
-
@Frederic-Baumann I have been doing some follow up on how Console sets the timezone.
As far as I can see this is done in /www/apps/onion-settings/onion-settings-general.html where it calls device.changeTimezone at around line 267.
The changeTimezone function is in /www/services/onion-device-provider/onion-device-provider.html which appears to use uci set and uci commit calls similar to what has been discussed in the posts above.HOWEVER As far as I can see, changing timezone in Console doesn't work in the current release. I believe that there is a bug in the code for changeTimezone function and possibly also in the call to it from onion-settings-general.html
I am going to be digging into this a bit deeper and will probably make a separate post covering what I think the bug is (and any fix I may come up with).
-
Thanks Kit.
We then agree that the code is in onion-settings-general.html.
I think there is a bug as I stated yesterday, around line 202, as zonenamePromise does not set the zone name but the time zone (redundantly to the other Promise right before it).
However, on my Omega, the Console DOES change the timezone (but not the zone name as expected with this bug).
And thanks for the Polymer tip, will check your URL.
-
@Frederic-Baumann Yes, agreed. Sorry I missed your earlier reference to line 202 in zonenamePromise - that is exactly what I had found too. Though changing the code to what I think it should be still doesn't work properly for me. I will dig further and let you know how it goes.