Skip to content

Modern Chrono LocalDate CompareTo

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

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

LocalDate.CompareTo

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

Syntax

LocalDate.CompareTo

Examples

#import "std/chrono"
using chrono

dim as LocalDate a = LocalDate( 2026, 1, 1 )
dim as LocalDate b = LocalDate( 2026, 8, 13 )

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

'' -2 when either side is Invalid -- NOT an ordering, so an invalid
'' date cannot silently sort to one end
print a.CompareTo( LocalDate.Invalid( ) )      '' -2

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

Clone this wiki locally