Subtracting two MonoTimes results in a Duration representing the amount of time which elapsed between them.
Adding or subtracting a Duration to/from a MonoTime results in a MonoTime which is adjusted by that amount.
Compares this MonoTime with the given MonoTime.
Adding or subtracting a Duration to/from a MonoTime results in a MonoTime which is adjusted by that amount.
The current time of the system's monotonic clock. This has no relation to the wall clock time, as the wall clock time can be adjusted (e.g. by NTP), whereas the monotonic clock always moves forward. The source of the monotonic time is system-specific.
Largest MonoTime possible.
Most negative MonoTime possible.
The number of ticks in the monotonic time.
The number of ticks that MonoTime has per second - i.e. the resolution or frequency of the system's monotonic clock.
A MonoTime of 0 ticks. It's provided to be consistent with Duration.zero, and it's more explicit than MonoTime.init.
Represents a timestamp of the system's monotonic clock.
A monotonic clock is one which always goes forward and never moves backwards, unlike the system's wall clock time (as represented by std.datetime.SysTime). The system's wall clock time can be adjusted by the user or by the system itself via services such as NTP, so it is unreliable to use the wall clock time for timing. Timers which use the wall clock time could easily end up never going off due to changes made to the wall clock time or otherwise waiting for a different period of time than that specified by the programmer. However, because the monotonic clock always increases at a fixed rate and is not affected by adjustments to the wall clock time, it is ideal for use with timers or anything which requires high precision timing.
So, MonoTime should be used for anything involving timers and timing, whereas std.datetime.SysTime should be used when the wall clock time is required.
The monotonic clock has no relation to wall clock time. Rather, it holds its time as the number of ticks of the clock which have occurred since the clock started (typically when the system booted up). So, to determine how much time has passed between two points in time, one monotonic time is subtracted from the other to determine the number of ticks which occurred between the two points of time, and those ticks are divided by the number of ticks that occur every second (as represented by MonoTime.ticksPerSecond) to get a meaningful duration of time. Normally, MonoTime does these calculations for the programmer, but the ticks and ticksPerSecond properties are provided for those who require direct access to the system ticks. The normal way that MonoTime would be used is
MonoTime is an alias to MonoTimeImpl!(ClockType.normal) and is what most programs should use for the monotonic clock, so that's what is used in most of MonoTimeImpl's documentation. But MonoTimeImpl can be instantiated with other clock types for those rare programs that need it.