Player APIs (BrightScript & Ja...
JavaScript APIs

systemtime

9min
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 interface systemtime { promise\<void> setdate(date date); promise\<void> settimezone(string timezone string); // requires reboot promise\<string> gettimezone(); promise\<lastnetworktimeresult> lastnetworktimeresult(); void addeventlistener(string type, networktimeeventcallback callback); void removeeventlistener(string type, networktimeeventcallback callback); }; interface lastnetworktimeresult { readonly attribute long successtimestamp; readonly attribute long attempttimestamp; readonly attribute string failurereason; }; 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(string timezone string) specifies a new time zone setting for the player (supported time zones are listed on rosystemtime docid\ hwr0zojgtzxxnuhdlhlf9 ) 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 gettimezone() as promise\<string> promise\<void> settimezone(string timezone string) returns the current time zone setting of the player a posix value is appended to the beginning of the string if the time zone has been set using the posix format lastnetworktimeresult() promise\<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 it contains the following read only attributes successtimestamp long long 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 attempttimestamp long long 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 failurereason string string 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 read only attributes success bool bool a flag indicating whether the last attempt to set the time via the network was successful or not reason string string 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 detail)); });