SystemClock Class

Definition

Contains methods to access and update the system real time clock ("Bios clock")

public class SystemClock : Iot.Device.Rtc.RtcBase
type SystemClock = class
    inherit RtcBase
Public Class SystemClock
Inherits RtcBase
Inheritance
SystemClock

Constructors

SystemClock()

Properties

DateTime

Set or retrieves the current date/time. This property returns a DateTimeOffset and is therefore correct regardless of the current time zone (when LocalTimeZone is set correctly).

(Inherited from RtcBase)
LocalTimeZone

We always use UTC when reading/writing the system clock, makes things easier. Technically, the BIOS RTC is configured in local time by default on Windows, but in UTC on Linux (causing weird effects when dual-booting). Both systems allow changing this setting, though.

RtcDateTime

The Device's raw DateTime. The caller must be aware of the device's time zone. The behavior of the Kind property is implementation-dependent (typically it is ignored)

(Inherited from RtcBase)

Methods

Dispose() (Inherited from RtcBase)
Dispose(Boolean)

Releases the unmanaged resources used by the RtcBase and optionally releases the managed resources.

(Inherited from RtcBase)
GetSystemTimeUtc()

Gets the current system time directly using OS calls. Normally, this should return the same as UtcNow

ReadTime()

Read time from the device

SetSystemTimeUtc(DateTime)

Set the system time to the given date/time. The time must be given in utc. The method requires elevated permissions. On Windows, the calling user must either be administrator or the right "Change the system clock" must have been granted to the "Users" group (in Security policy management). On Unix and MacOs, the current user must be root or the "date" command must have the setUid bit set.

SetTime(DateTime)

Set the device time

Applies to