We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Time and date initialization

  • Hi,

    I am wondering how the date+time is initialized on the Omega.

    I guess there is no onboard clock battery, and that there is some time-server query that is done on the internet or to the local wifi??

    Also, if you can explain me how the timezone is set? normally it is stored in the TZ env variable, but I cannot see it set on my Omega. However there is a /etc/timezone file mentioning my town, but I can't remember if I have set it manually from the console, or if it has been set automatically.

    Thanks in advance - even partial answers will be welcome!

  • @Frederic-Baumann Regarding how the Omega gets its date and time - I don't know but have always assumed that it accesses some time server.

    Regarding where the timezone information is held - it is kept in he file /etc/TZ and I have only ever set it using Console->Settings->General Settings->Timezone

    I don't see any /etc/timezone file on my Omega.

  • Thanks Kit for your answer!

    funny and strange for the /etc/TZ file. I was expecting one as it's OpenWRT standard, and dit not find it, but found /etc/timezone instead on my Omega... So I wonder what makes the Omega chose for one or the other...

    Regarding the time server, if anyone can give more insights that would be great.

    I think I have never set the time zone on my Omega (not 100% sure unfortunately), so as my time mentions a time zone corresponding to my location, I suspect that this time server also locates the IP address of the Omega to embed the timezone in the time update.

    If I could get a confirmation (or negation) of this assumption that would really help.


  • administrators

    The Omega gets it's time and date info automatically from the OpenWRT NTP servers.

    The timezone is defined in /etc/config/system, as are the default NTP servers

  • Thanks a lot Lazar, this does help.

    Just had a look at that file, and wonder how is the time zone set.

    In my case there is "option timezone 'CET-1CEST,M3.5.0,M10.5.0/3'".

    Is this automatically set from the answer of the time server? For my project it's important to know whether this information is based on user input, or automatically from a server.

    Thanks again!

  • administrators

    @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"):

    1. when I change the timezone through the console, the /etc/config/system still indicates "UTC" as zonename

    2. 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 system

    This 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:

    1. uci set system.@system[0].timezone=XYZ
    2. uci commit system
    3. /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)


  • @Frederic-Baumann I have done some playing with your suggestion of using:

    1. uci set system.@system[0].timezone=XYZ
    2. uci commit system
    3. /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:

    1. As well as doing uci set system.@system[0].timezone=XYZ also do a uci set system.@system[0].zonename="zone-description"
    2. 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:

    1. As well as doing uci set system.@system[0].timezone=XYZ also do a uci set system.@system[0].timezone="zone-description""


    1. 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.

Looks like your connection to Community was lost, please wait while we try to reconnect.