32b4063185
* Clarify intent * Increase email reminder period to once per day * Fallback * Snooze immediately after account creation, prevent showing right after signup * Fix e2e test exports * Remove redundant check * Better simple date generation * Replace in DateField * Use non-string comparison * Revert change to unrelated code * Also parse * Remove side effect
33 lines
823 B
TypeScript
33 lines
823 B
TypeScript
export function niceDate(date: number | string | Date) {
|
|
const d = new Date(date)
|
|
return `${d.toLocaleDateString('en-us', {
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
})} at ${d.toLocaleTimeString(undefined, {
|
|
hour: 'numeric',
|
|
minute: '2-digit',
|
|
})}`
|
|
}
|
|
|
|
export function getAge(birthDate: Date): number {
|
|
var today = new Date()
|
|
var age = today.getFullYear() - birthDate.getFullYear()
|
|
var m = today.getMonth() - birthDate.getMonth()
|
|
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
|
|
age--
|
|
}
|
|
return age
|
|
}
|
|
|
|
/**
|
|
* Compares two dates by year, month, and day only
|
|
*/
|
|
export function simpleAreDatesEqual(a: Date, b: Date): boolean {
|
|
return (
|
|
a.getFullYear() === b.getFullYear() &&
|
|
a.getMonth() === b.getMonth() &&
|
|
a.getDate() === b.getDate()
|
|
)
|
|
}
|