Time
Management API time allows you to check your devices current time with a timezone and set current time with a timezone.
All methods
Method | Description | Supported since |
---|---|---|
get() | Get current time settings | 4.0.0 |
setManual() | Set manual datetime and timezone | 4.0.0 |
setNTP() | Configure NTP server and timezone | 4.0.0 |
set() | Set manual datetime and timezone (DEPRECATED) | 4.0.0 |
get()
Method get()
lets you check for current time with time zone.
Javascript example
const time = await sos.management.time.get();
Example of response
When NTP is set:
{
"currentDate": Date("2019-04-01T01:11:11.111Z"),
"timezone": "Asia/Tokyo",
"ntpServer": "pool.ntp.org"
}
When NTP is not set:
{
"currentDate": Date("2019-04-01T01:11:11.111Z"),
"timezone": "Asia/Tokyo"
}
set()
Method set()
lets you set manual time and timezone of the device.
This method is deprecated. Use setManual()
instead.
Calling set()
will disable NTP server settings.
Param | Type | Required | Description |
---|---|---|---|
currentDate | Date | Yes | Datetime to set |
timezone | String | Yes | Timezone to set. Accepted values are timezone names from timezone database. |
Javascript example
const currentDate = new Date();
const timezone = "Europe/Amsterdam";
await sos.management.time.set(currentDate, timezone);
Setting time and timezone has side effects:
Platform | Side effect |
---|---|
Tizen | After calling this API, display Reboots! |
webOS | After calling this API, display Reboots! |
RaspberryPi | After calling this API, RPi Reboots backend server which can take up to 60 seconds! During the reboot no JS API is available. Always wait for Promise resolution. |
setManual()
Method setManual()
lets you set manual time and timezone of the device.
Calling setManual()
will disable NTP server settings.
Param | Type | Required | Description |
---|---|---|---|
currentDate | Date | object | Yes | Datetime to set |
timezone | String | Yes | Timezone to set. Accepted values are timezone names from timezone database. |
Javascript example
const datetimeObj = {
year: 2021,
month: 12,
day: 15,
hour: 9,
minute: 30,
seconds: 0,
};
const timezone = "Europe/Amsterdam";
await sos.management.time.setManual(datetimeObj, timezone);
// Using Date is deprecated. Use the example above.
const currentDate = new Date();
const timezone = "Europe/Amsterdam";
await sos.management.time.setManual(currentDate, timezone);
Calling this method with currentDate as Date is deprecated. You should call it with datetime object instead. See example code.
Setting time and timezone has side effects:
Platform | Side effect |
---|---|
Tizen | After calling this API, display Reboots! |
webOS | After calling this API, display Reboots! |
RaspberryPi | After calling this API, RPi Reboots backend server which can take up to 60 seconds! During the reboot no JS API is available. Always wait for Promise resolution. |
setNTP()
Method setNTP()
lets you configure NTP server and timezone.
Param | Type | Required | Description |
---|---|---|---|
ntpServer | string | Yes | Address of the NTP server |
timezone | string | Yes | Timezone to set. Accepted values are timezone names from timezone database. |
Javascript example
const ntpServer = "pool.ntp.org";
const timezone = "Europe/Amsterdam";
await sos.management.time.setNTP(ntpServer, timezone);
Setting NTP server and timezone has side effects:
Platform | Side effect |
---|---|
Tizen | After calling this API, display Reboots! Tizen has limited set of available timezones. Read more here. |
RaspberryPi | After calling this API, RPi Reboots backend server which can take up to 60 seconds! During the reboot no JS API is available. Always wait for Promise resolution. |