@@ -96,6 +96,11 @@ export function getGithubUrl(username?: string) {
96
96
return speaker_photo
97
97
}
98
98
99
+ /**
100
+ * Returns the timestamp in milliseconds for the given date at midnight.
101
+ * @param {Date } date - The date to convert
102
+ * @returns {number } Timestamp in milliseconds
103
+ */
99
104
function dateAtMidnightInMs ( date : Date ) {
100
105
const clonedDate = new Date ( date )
101
106
@@ -104,14 +109,32 @@ function dateAtMidnightInMs(date: Date) {
104
109
return clonedDate . getTime ( )
105
110
}
106
111
112
+ /**
113
+ * Checks if the given date is in the future relative to the reference date.
114
+ * @param {Date } date - The date to check
115
+ * @param {Date } now - The reference date (defaults to the current date)
116
+ * @returns {boolean } True if the date is in the future, false otherwise
117
+ */
107
118
export function isDateInFuture ( date : Date , now : Date = new Date ( ) ) {
108
119
return dateAtMidnightInMs ( date ) > dateAtMidnightInMs ( now )
109
120
}
110
121
122
+ /**
123
+ * Checks if the given date is in the past relative to the reference date.
124
+ * @param {Date } date - The date to check
125
+ * @param {Date } now - The reference date (defaults to the current date)
126
+ * @returns {boolean } True if the date is in the past, false otherwise
127
+ */
111
128
export function isDateInPast ( date : Date , now : Date = new Date ( ) ) {
112
129
return dateAtMidnightInMs ( date ) < dateAtMidnightInMs ( now )
113
- } ;
130
+ }
114
131
132
+ /**
133
+ * Checks if the given date is the same as the reference date.
134
+ * @param {Date } date - The date to check
135
+ * @param {Date } now - The reference date (defaults to the current date)
136
+ * @returns {boolean } True if the date is the same as the reference date, false otherwise
137
+ */
115
138
export function isDateToday ( date : Date , now : Date = new Date ( ) ) {
116
139
return dateAtMidnightInMs ( date ) === dateAtMidnightInMs ( now )
117
- } ;
140
+ }
0 commit comments