time
The sos.management.time
API groups together methods for working with the system time.
Methods
get()
The get()
method returns currently set time info.
get(): Promise<IGetTime>;
setManual(dateTime, timezone)
The setManual()
method sets the system time and the system timezone and disables NTP server settings.
Setting NTP server and timezone has side effects
- 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.
setManual(dateTime: DateTime, timezone: string): Promise<void>;
Params
Name | Type | Description |
---|---|---|
dateTime | DateTime | The date and time to set. |
timezone | string | The timezone to set. |
setNTP()
The setNTP()
method sets the NTP server and the system timezone.
Setting NTP server and timezone has side effects
- Tizen / WebOS: 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.
setNTP(ntpServer: string, timezone: string): Promise<void>;
Params
Name | Type | Description |
---|---|---|
ntpServer | string | The NTP server to set. |
timezone | string | The timezone to set. |
set()
Deprecated
This method was deprecated. Use setManual(dateTime, timezone)
instead.
set(currentDate: Date, timezone: string): Promise<void>;
setManual(currentDate, timezone)
Deprecated
This method was deprecated. Use setManual(dateTime, timezone)
instead.
setManual(currentDate: Date, timezone: string): Promise<void>;
API Example
import { sos } from '@signageos/front-applet';
void sos.onReady(async () => {
const { currentDate, timezone, ntpServer } = await sos.management.time.get();
console.log({ currentDate, timezone, ntpServer });
// Set the time without a ntp server
await sos.management.time.setManual(
{
year: 2025,
month: 5,
day: 23,
hour: 13,
minute: 0,
second: 0,
},
'Europe/Amsterdam',
);
// Set the time with a ntp server
await sos.management.time.setNTP('pool.ntp.org', 'Europe/Amsterdam');
});