import IPostMessage from '../../IPostMessage'; import ITime, { DateTime, IGetTime } from './ITime'; /** * The `sos.management.time` API groups together methods for working with the system time. * *
* Time Management Capabilities * | Capability | Description | * |:------------|:-------------| * | `SET_TIME` | If the device can set the system time. | * | `SET_TIMEZONE` | If the device can set the system timezone. | * | `GET_TIMEZONE` | If the device can get the system timezone. | * | `NTP_TIME` | If the device can set the NTP server and system timezone. | * * If you want to check if the device supports those capabilities, use [`sos.management.supports()`](https://developers.signageos.io/sdk/sos_management/#supports). *
*/ export default class Time implements ITime { private messagePrefix; private postMessage; /** @internal */ constructor(messagePrefix: string, postMessage: IPostMessage); /** * The `get()` method returns the currently set time from the device. * * @returns {Promise} A promise that resolves to the current time with timezone. * @throws {Error} If the time cannot be retrieved. * @since 4.0.0 * * @example * const currentTime = await sos.management.time.get(); * console.log(`Current time is: ${currentTime.currentDate} in timezone ${currentTime.timezone}`); */ get(): Promise; /** @deprecated Use `setManual(dateTime, timezone)` instead. */ set(currentDate: Date, timezone: string): Promise; /** @deprecated Use `setManual(dateTime, timezone)` instead. */ setManual(currentDate: Date, timezone: string): Promise; /** * The `setManual()` method sets the system time and the system timezone and disables NTP server settings. * * :::warning Setting NTP server and timezone has side effects * - **Tizen**: After calling this API, display Reboots! * Tizen has a limited set of available timezones. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405381271314-Tizen-Timezones-Limited-List-for-NTP). * - **RaspberryPi**: After calling this API, RPi Reboots the backend server, which can take up to 60 seconds! During the reboot, no JS API is * available. **Always wait for Promise resolution.** * ::: * * @param dateTime The date and time to set. * @param timezone The timezone to set. * @returns {Promise} A promise that resolves when the time is successfully set. * @throws {Error} If `dateTime` is not a valid Date or DateTime object. * @throws {Error} If `timezone` is not a valid string. * @throws {Error} If the time cannot be set. * @since 4.0.0 * * @example * // Set the system time to 2023-10-01T12:00:00 in Europe/Prague timezone * const dateTime = { * year: 2023, * month: 10, * day: 1, * hour: 12, * minute: 0, * second: 0, * } * await sos.management.time.setManual(dateTime, 'Europe/Prague'); */ setManual(dateTime: DateTime, timezone: string): Promise; /** * The `setNTP()` method sets the NTP server and the system timezone. * * :::warning Setting NTP server and timezone has side effects * - **Tizen / WebOS**: After calling this API, display Reboots! * Tizen has a limited set of available timezones. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405381271314-Tizen-Timezones-Limited-List-for-NTP). * - **RaspberryPi**: After calling this API, RPi Reboots the backend server, which can take up to 60 seconds! During the reboot, no JS API is * available. **Always wait for Promise resolution.** * ::: * * @param ntpServer The NTP server to set. * @param timezone The timezone to set. * @return {Promise} A promise that resolves when the NTP server and timezone are successfully set. * @throws {Error} If `ntpServer` is not a valid string. * @throws {Error} If `timezone` is not a valid string. * @throws {Error} If the NTP server and timezone cannot be set. * @since 4.0.0 * * @example * // Set the NTP server to `pool.ntp.org` and timezone to `Europe/Prague` * await sos.management.time.setNTP('pool.ntp.org', 'Europe/Prague'); */ setNTP(ntpServer: string, timezone: string): Promise; private getMessage; }