| 94 | // having the same representation in local time, e.g. one hour before |
| 95 | // DST ends vs. the instant that DST ends. |
| 96 | function compareLocalAsc(laterDate: Date, earlierDate: Date): number { |
| 97 | const diff = |
| 98 | laterDate.getFullYear() - earlierDate.getFullYear() || |
| 99 | laterDate.getMonth() - earlierDate.getMonth() || |
| 100 | laterDate.getDate() - earlierDate.getDate() || |
| 101 | laterDate.getHours() - earlierDate.getHours() || |
| 102 | laterDate.getMinutes() - earlierDate.getMinutes() || |
| 103 | laterDate.getSeconds() - earlierDate.getSeconds() || |
| 104 | laterDate.getMilliseconds() - earlierDate.getMilliseconds(); |
| 105 | |
| 106 | if (diff < 0) return -1; |
| 107 | if (diff > 0) return 1; |
| 108 | |
| 109 | // Return 0 if diff is 0; return NaN if diff is NaN |
| 110 | return diff; |
| 111 | } |