Class: Toybox.Time.Moment
- Inherits:
-
Toybox.Lang.Object
Overview
A Moment is an immutable moment in time.
Moment objects are closely related to Duration objects, and are frequently used together for time calculations. While a Duration represents a span of time, a Moment represents a single point in time such as a specific date.
Internally, Moment objects are stored as 32-bit integers representing the number of seconds since the UNIX epoch (January 1, 1970 at 00:00:00 UTC).
See Also:
Instance Method Summary collapse
-
add(duration as Time.Duration) as Time.Moment
Add a Duration to a Moment.
-
compare(moment as Time.Moment) as Lang.Number
Determine if a Moment is before or after another Moment.
-
greaterThan(moment as Time.Moment) as Lang.Boolean
Determine if a Moment is greater than another Moment.
-
initialize(seconds as Lang.Number) Time.Moment
Constructor.
-
lessThan(moment as Time.Moment) as Lang.Boolean
Determine if a Moment is less than another Moment.
- subtract(subtrahend as Time.Moment or Time.Duration) as Time.Moment or Time.Duration
-
value() as Lang.Number
Get the UTC value of a Moment.
Instance Method Details
add(duration as Time.Duration) as Time.Moment
Add a Duration to a Moment.
This method functions the same as the Duration.add() method when adding a Duration to a Moment.
compare(moment as Time.Moment) as Lang.Number
Determine if a Moment is before or after another Moment.
This computes a Number representing the difference between the two Moment objects in seconds. The subtract() method can also be used to get the absolute Duration between two Moment objects.
greaterThan(moment as Time.Moment) as Lang.Boolean
Determine if a Moment is greater than another Moment.
initialize(seconds as Lang.Number) Time.Moment
Constructor
lessThan(moment as Time.Moment) as Lang.Boolean
Determine if a Moment is less than another Moment.
subtract(subtrahend as Time.Moment or Time.Duration) as Time.Moment or Time.Duration
Subtracting a Duration from a Moment was not supported until ConnectIQ 3.0.0. If backward compatibility is a concern, it may be best to add a negative Duration instead.
value() as Lang.Number
Get the UTC value of a Moment.