summaryrefslogtreecommitdiff
path: root/source/storage/TimeSource.mc
blob: 426a56a755ec01e0eeda37908d09b250fa2f080c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Author:  cirakg & claude ai
// Summary: The clocks the PIN lockout uses, behind a class so tests can inject a fake clock.
//
// Lockout delays use the trusted clock (GPS-synced, not user-adjustable) when
// it is synced, and the system uptime timer otherwise (README 7.6). Tests
// replace this class with one whose clocks they set by hand, which makes the
// lockout schedule, restarts and clock loss testable.

import Toybox.Lang;
import Toybox.System;

class TimeSource {

    function initialize() {
    }

    // Trusted unix time in seconds, or null when the trusted clock isn't synced.
    function trustedUnix() as Long? {
        return Clock.trustedUnix();
    }

    // Milliseconds from the system timer. It restarts at zero when the watch
    // restarts and wraps after about 24.8 days.
    function uptimeMs() as Number {
        return System.getTimer();
    }
}