Home  Contents

clock.setDateTime

Date/Time Core4 Lua Commands

SYNOPSIS

  1. clock.setDateTime(datetime)
  2. clock.setDateTime(date, time)
  3. clock.setDateTime(year, month, day, hour, minute[, second[, millisecond]])

DESCRIPTION

This will set the system clock to the passed value and save it to the battery-backed hardware clock.

The first variant takes a datetime instance, the second variant uses separate date and time instances, while the last variant takes all values as numbers.

The system clock always runs in the UTC time zone. Before setting the system clock, convert any user input from local time to UTC by calling datetime:toUTC().

RETURN VALUE

On success, returns true. On error, three values are returned: nil, a string describing the error (The result of the C library call strerror() on the errno code) and the errno number from the standard C library.

BUGS

On Core4 OS, setting the hardware clock may block the current process up to one second, while the clock is synchronized.

SEE ALSO