Skip to content

ClockLocal

Description

Current wall-clock instant broken down in the host’s local time. The local UTC offset is resolved from /etc/localtime (TZif) on POSIX. If the host timezone cannot be determined, falls back to UTC and the result’s utc_offset_seconds is 0.

Success

Returns the current local DateTime; utc_offset_seconds holds the resolved offset (0 if it fell back to UTC).

Failure

Aborts via LOG_FATAL only if the underlying clock query fails (see ClockRealNs). A missing/unreadable timezone is a soft fallback to UTC, not a failure.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    DateTime ClockLocal(void) {
        u64 ns = ClockRealNs();
    #if FEATURE_FILE
    // timezone resolves (it falls back to UTC, offset 0).
    static bool test_clock_local_sane(void) {
        DateTime d = ClockLocal();
        return d.year >= 2024 && d.month >= 1 && d.month <= 12 && d.day >= 1 && d.day <= 31 && d.hour <= 23 &&
               d.minute <= 59;
Last updated on