hardhat
Version:
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
16 lines (12 loc) • 420 B
text/typescript
export function parseDateString(str: string): Date {
return new Date(str);
}
export function dateToTimestampSeconds(date: Date): number {
return Math.floor(date.valueOf() / 1000);
}
export function timestampSecondsToDate(timestamp: number): Date {
return new Date(timestamp * 1000);
}
export function getDifferenceInSeconds(a: Date, b: Date): number {
return Math.floor((a.valueOf() - b.valueOf()) / 1000);
}