Time and Date Registry Settings (Compact 2013)
3/28/2014
Learn how to use registry settings for time and date in the Windows Embedded Compact 2013 OS, including time zone and synchronization.
Introduction
This topic describes time-related registry key settings at the device's operating system level. For daylight saving time registry settings, see Daylight Saving Time Registry Settings.
Windows Embedded Compact provides the following registry keys for dealing with time and date issues.
Key |
Description |
---|---|
HKEY_LOCAL_MACHINE\SYSTEM\State\Clock |
Enables network time zone synchronization. Available to end users. For more information, see Enabling Network Time Zone Synchronization. |
HKEY_LOCAL_MACHINE\SYSTEM\State\DateTime |
Displays the network time zone synchronization user interface on the Date and Time panel when a synchronization has occurred. For more information, see Enabling Network Time Zone Synchronization. |
HK_LOCAL_MACHINE\System\State\DateTime\Date |
Enables monitoring of date changes in local time. See Local Time Date Change Settings. |
HKEY_LOCAL_MACHINE\Time |
Controls time zone information on a running device. See Setting System Time Zone Information. |
HKEY_LOCAL_MACHINE\Time Zones |
Controls time zone information when a device is turned on. See Setting System Time Zone Information. |
Setting System Time Zone Information
System time information is specified by various registry key settings under HKEY_LOCAL_MACHINE\Time and HKEY_LOCAL_MACHINE\Time Zones, plus the TIME_ZONE_INFORMATION and TZREG structures.
To set time zone information while the target device is running, use the following registry key:
[HKEY_LOCAL_MACHINE\Time]
"TimeZoneInformation": (REG_BINARY): TIME_ZONE_INFORMATION (structure)
To set time zone information during a cold boot, use the following registry key:
[HKEY_LOCAL_MACHINE\Time Zones]
"@": REG_SZ
The default data value of the Time Zones key is the standard time zone name used as the default time zone for the device during a cold boot. The registry key uses the standard time zone name if the TIME_ZONE_INFORMATION structure is not available. The name of the time zone corresponds to one of the following additional time zone entries that are used to provide information for a specified time zone:
[HKEY_LOCAL_MACHINE\Time Zones\Standard time zone name]
"TZI": REG_BINARY
"Dlt": REG_SZ
"Std": REG_SZ
The standard time zone name corresponds to the StandardName member of the TIME_ZONE_INFORMATION structure, so the same rules and conditions that apply to the structure apply to this registry key.
You can create a separate entry in the registry for each time zone. For details, see the Common.reg file.
The TZI registry data value corresponds to the TZREG structure, which is defined as follows:
typedef struct tagTZREG { LONG Bias; LONG StandardBias; LONG DaylightBias; SYSTEMTIME StandardDate; SYSTEMTIME DaylightDate; } TZREG;
The Dlt registry value is the name used for daylight saving time. Because this value corresponds to the DaylightName member of the TIME_ZONE_INFORMATION structure, the same rules and conditions that apply to the structure apply to this registry value. For more information on how to set the operating system to daylight saving time, see Daylight Saving Time Registry Settings.
The Std registry value corresponds to a translated string to display the standard time name of the time zone.
A call to the GetTimeZoneInformation function retrieves the TIME_ZONE_INFORMATION structure. The data in the TIME_ZONE_INFORMATION structure provides the information that the function returns. If the structure is not found, the @ data value of the Time Zones subkey, which is the default value, is retrieved. If this value is missing, the Pacific Time Zone is used.
A call to the SetTimeZoneInformation function sets the registry TimeZoneInformation data value to the TIME_ZONE_INFORMATION structure passed into the function. In addition, the NOTIFICATION_EVENT_TIME_CHANGE notification event is triggered.
When it starts, the OS makes a call to the GetTimeZoneInformation function to set time zone information.
Enabling Network Time Zone Synchronization
When a user travels to a location in a different time zone, the mobile device detects whether the mobile network supports network time zone synchronization, and if so, asks the user whether to update the time manually or do it automatically depending on the setting.
Two DateTime registry keys and two Clock registry keys control this functionality. The DateTime registry keys are accessible only to OEMs. The Clock registry keys are accessible to end users, and appear as check boxes in the Date and Time panel, labeled Sync to current time zone and Notify me when time is updated.
DateTime Registry Settings
The DateTime registry keys are accessible only to OEMs. The following table describes the time zone synchronization values for the HKEY_LOCAL_MACHINE\SYSTEM\State\DateTime registry key.
Value |
Type |
Description |
---|---|---|
NetworkTime Enabled |
DWORD |
Displays or hides the network time zone synchronization user interface on the Date and Time panel. A value of zero (the default) hides the Network Time Zone user interface, and a value of 1 displays it. This setting is not available to end users. |
NetworkTimeNotifyValue |
DWORD |
Specifies the number of minutes the device must be ahead or behind network time before the end user is notified that a synchronization has occurred. Automatic network time zone synchronizations will occur regardless of this setting, which specifies only when the device notifies the user of an update.
This setting is used in conjunction with NetworkTimeNotifyUser. For more information, see Code Examples, below. This setting is not available to end users. |
Clock Registry Settings
The Clock registry keys are accessible to end users; their settings appear as check boxes in the Date and Time panel. The following table describes the named values for the HKEY_LOCAL_MACHINE\SYSTEM\State\Clock registry key.
Value |
Type |
Description |
---|---|---|
NetworkTimeSync |
DWORD |
Enables or disables network time zone synchronization. This setting allows end users to turn the automatic network time zone synchronization feature on or off. When this is enabled, the device acts on messages from the mobile network to update the date and time. It appears in the user interface as a check box labeled Sync to current time zone. A value of zero (the default) disables network time zone synchronization, and a value of 1 enables it. |
NetworkTimeNotifyUser |
DWORD |
Enables or disables network time zone synchronization notifications. This setting allows end users to receive notifications when a network time update occurs. It appears in the user interface as a check box labeled Notify me when time is updated. A value of 1 (the default) enables the notifications; a value of 0 disables notifications. This setting is used in conjunction with NetworkTimeNotifyValue. If notifications are disabled, NetworkTimeNotifyValue is ignored. For more information, see "Code Examples" below. |
Code Examples
The following code example shows how to register this value. NetworkTimeSync enables network time zone synchronization and NetworkTime Enabled displays the network time zone synchronization user interface on the Date and Time panel.
This example also shows how NetworkTimeNotifyUser and NetworkTimeNotifyValue work together. In this code, NetworkTimeNotifyUser enables notifications and NetworkTimeNotifyValue sets the notification time to 1 hour. The network time zone synchronization feature updates the user's device automatically, but the user is notified only when the difference between the device's time and network time is at least one hour.
[HKEY_LOCAL_MACHINE\System\State\DateTime]
"NetworkTime Enabled"=dword:1
"NetworkTimeNotifyValue"=dword:60
[HKEY_LOCAL_MACHINE\Software\Microsoft\Clock]
"NetworkTimeSync"=dword:1
"NetworkTimeNotifyUser"=dword:0
Local Time Date Change Settings
The HK_LOCAL_MACHINE\System\State\DateTime registry key enables monitoring of date changes in local time. It is set as shown in the following example:
[HK_LOCAL_MACHINE\System\State\DateTime]
"LocalDate" : Binary Value
The value is a local FILETIME that is stored in REG_BINARY format.
This value obtains the current date once per day at midnight local time. Monitor this property to perform actions on a daily basis at a specified local time.
To get an accurate clock time, use the Time value of this registry key instead of the LocalDate value.
A similar registry key exists for date change in UTC time: HK_LOCAL_MACHINE\System\State\DateTime\Date.