Skip to content

Modern Chrono Instant CompareTo

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Date and Time (Chrono) › Chrono Date and Time › Instant.CompareTo

Instant.CompareTo

Returns -1, 0 or 1 to order two moments, or -2 if either is Invalid.

Syntax

Instant.CompareTo

Examples

#import "std/chrono"
using chrono

dim as Instant a = Instant.FromUnixSeconds( 0 )
dim as Instant b = Instant.FromUnixSeconds( 86400 )

print a.CompareTo( b )       '' -1
print b.CompareTo( a )       '' 1
print a.CompareTo( a )       '' 0

'' -2 when either side is Invalid, so it cannot silently sort to one end
print a.CompareTo( Instant.Invalid( ) )      '' -2

Library: Chrono Date and Time
Category: Date and Time (Chrono)
Documented under: The Members

Clone this wiki locally