Page tree
Skip to end of metadata
Go to start of metadata

ON THIS PAGE

The systemtime object provides the ability to read and write the time stored in the real-time clock (RTC). It can also be used to read and write the time-zone setting.

systemtime IDL
[
    GarbageCollected,
] interface SystemTime : EventTarget {
   Promise <> setDate(Date date);
   Promise <> setTimeZone(DOMString timezone_string); // requires reboot
   LastNetworkTimeResult lastNetworkTimeResult();
   attribute EventHandler networktimeevent;
};

interface LastNetworkTimeResult {
   readonly long successTimestamp;
   readonly long attemptTimestamp;
   readonly DOMString failureReason;
};

interface NetworkTimeEvent : Event {
   readonly attribute bool success;
   readonly attribute DOMString reason;
};

Object Creation

To create a systemtime object, first load the brightsign/systemtime module using the Require() method. Then create an instance of the systemtime class.

var systemTimeClass = require("@brightsign/systemtime");
var systemTime = new systemTimeClass();

SystemTime

Use this interface to set the date and time zone and retrieve network time data.

Events

  • [EventHandler] networktimeevent:  An event that is is raised when the player attempts to update its clock via the network. Use the addEventListener() method to listen for this event. Results are returned as a NetworkTimeEvent interface.

Methods

setDate()
Promise <void> setDate(Date date) 

Specifies a new time for the RTC using the current time zone.

setTimeZone()
Promise <void> setTimeZone(DOMString timezone_string) 

Specifies a new time-zone setting for the player (supported time zones are listed here). Alternatively, a POSIX-formatted time zone can be applied by appending a POSIX: value to the beginning of the string. This method requires a reboot to go into effect.

lastNetworkTimeResult()
 LastNetworkTimeResult lastNetworkTimeResult()

Returns a LastNetworkTimeResult interface containing information about the last attempt to set the time via the network.

LastNetworkTimeResult

This interface contains information about the last attempt to set the time via the network:

  • readonly [long] successTimestamp: A value indicating when (in seconds) the clock was last set successfully via the network. This value is zero if the clock has never been set successfully via the network.
  • readonly [long] attemptTimestamp: A value indicating when (in seconds) the last attempt was made to set the clock via the network. This value is zero if no attempt has been made yet.
  • readonly [DOMString] failureReason:  If the last attempt to set the clock via the network failed, this string will contain an error message. If the last attempt was successful, this string will be empty.

NetworkTimeEvent

This interface is returned by the event listener for networktimeevent. It contains the following attributes:

  • readonly [bool] success: A flag incading whether the last attempt to set the time via the network was successful or not.
  • readonly [DOMString] reason: An error message that will be included if the last attempt failed.

Example

var SystemTimeClass = require("@brightsign/systemtime");
var systemTime = new SystemTimeClass();

//Set the date to 2018
var date = new Date();
date.setFullYear(2018);
systemTime.setDate(date);

//Set the time zone
systemTime.setTimeZone("PST")

//Listen for a network time event
systemTime.addEventListener("networktimeevent",
    function(data) {
        console.log("Last network update:" + JSON.stringify(data));
    });
  • No labels

2 Comments

  1. systemtime IDL continously spins and never shows up on Chromium69 Linux.

  2. It did show up after quite a long wait....