Motorola Mobility Confidential Restricted.

Time Service

The Time Service is responsible for setting the time zone and maintaining the system time on the STB. The service does not have a TOI interface but uses information objects. If the clock of the STB drifts from the time received from the source, the service will slowly adjust the time to avoid sudden changes which may affect applications and platform services in an unexpected way.

Time Sources

Currently there are four available time sources:

  • NTP and SNTP (simpler version of ntp) are wide spread ways of distributing time over an Internet connection.
  • Timecast is Motorola's own way of distributing time through a multicasted connection. It is based on the Infocast server which sets up a special channel where STB can listen for time messages.
  • DVB is a way of parsing time through DVB TDT/TOT tables.

Time Source Configuration

To select time source, add one of following IIPs to your build configuration:

kreatv-option-ntp
kreatv-option-sntp
kreatv-option-timecast
kreatv-option-dvbtime

Note! Only one of the above IIPs could be added to build config file. Support for having more than one time source in a boot image may be added in future versions of KreaTV.

The Time Service will check the selected IIP and set the value of the information object const.time.available_sources. The value set is {ntp|sntp|timecast|dvb}.

Time Zone Configuration

It is possible to configure the timezone in build time by adding the "kreatv-option-tz:[time zone value]" in the build config file. DHCP option tz-posix is supported to change the timezone by adding "option tz-posix [time zone value]" in the DHCP config file. The timezone can also be changed in run-time by updating the cfg.locale.timezone information object with a string of the same format. If the information object has not been set by the user, the time zone set at build time can be read from the object.

Time Zone String Format

The following is an example of a time zone string:

kreatv-option-tz:CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00

There are two different flavors for the string format:

std offset
std offset[dst[offset][,start[/time],end[/time]]]

The first format is used when there is no DST (daylight savings time) for the country or region in question. The second format is used when a country or region has DST in place.

The format for each part of a time zone string is as follows:

  • std, dst: These two variables must be three or more characters long and must not contain a leading colon, embedded digits, commas, nor plus and minus signs. There is no space character separating the time zone name from the offset, so these restrictions are necessary to parse the specification correctly. If dst lacks a value then the daylight savings time offset is taken to be one hour by default.
  • offset: Specifies the time value that must be added to the local time to get a UTC value. It has syntax like [+|-]hh[:mm[:ss]]. This is positive if the local time zone is west of the Prime Meridian and negative if it is east. The hour must be between 0 and 23, and the minute and seconds between 0 and 59.
  • The last part is called a rule and has the form date[/time],date[/time]. There are three formats for describing time:
    • Jn: The Julian day where n is between 1 and 365 and the 29 of February is never counted.
    • n: Here n ranges between 0 and 365. February 29 is counted in leap years.
    • Mm.n.d: Probably the most common format. The d'th day (d: 0-6) of week n of month m of the year (n: 1-5, m: 1-12, where week 5 means "the last d day in month m" which may occur in either the fourth or the fifth week). Week 1 is the first week in which the d'th day occurs. Day zero is Sunday.

Time Zone String Examples

Examples best describe the formats.

EST+5. Eastern Time Zone, five hours behind UTC time.

WST-10. Western Time Zone, ten hours ahead of UTC.

EST+5EDT,M4.1.0/2,M10.5.0/2. Eastern Time Zone, five hours behind UTC time. The DST time is Eastern Daylight Time which is applicable from the first Sunday in April at 2 AM and ends on the last Sunday i in October at 2 AM.

Time Service Behavior

The Time Service is alone responsible for the entire time keeping. No application or other platform service should change the clock by calling system time functions. The Time Service handles the following information objects.

  • cfg.locale.timezone. By time zone data we mean both the offset from the UTC and the DST values for a given time zone. The Time Service will change time zone if this object is updated.
  • var.utctime. This object is set by timecast and shall not be used by applications or platform services to get the current time. The Time Service subscribes to this to keep track of the distributed time information.
  • var.time.valid. This object is set by the Time Service when a valid system time has been set. Applications can observe this to know when it is safe to trust the clock in the system. When the value is "TRUE", no sudden changes of the clock will occur, only slow adjustment to keep the time correct.