MCPcopy Create free account
hub / github.com/codemix/graph / compareTo

Method compareTo

packages/graph/src/TemporalTypes.ts:1009–1031  ·  view source on GitHub ↗
(other: DateTimeValue)

Source from the content-addressed store, hash-verified

1007 }
1008
1009 public compareTo(other: DateTimeValue): number {
1010 // Compare by UTC instant
1011 const thisUTC =
1012 new Date(
1013 Date.UTC(this.#year, this.#month - 1, this.#day, this.#hour, this.#minute, this.#second),
1014 ).getTime() -
1015 this.#offsetSeconds * 1000;
1016 const otherUTC =
1017 new Date(
1018 Date.UTC(
1019 other.#year,
1020 other.#month - 1,
1021 other.#day,
1022 other.#hour,
1023 other.#minute,
1024 other.#second,
1025 ),
1026 ).getTime() -
1027 other.#offsetSeconds * 1000;
1028
1029 if (thisUTC !== otherUTC) return thisUTC - otherUTC;
1030 return this.#nanosecond - other.#nanosecond;
1031 }
1032}
1033
1034/**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected