Skip to content

Commit

Permalink
Update date.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Jan 14, 2025
1 parent 1e0bab0 commit 6bc1073
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,12 @@ export function dateToUnixTimestamp(date: Date): number {
return Math.round(date.getTime() / 1000);
}

// use `as const` instead of enum
// https://www.totaltypescript.com/books/total-typescript-essentials/deriving-types#using-as-const-for-javascript-style-enums
export const DateFormat = {
DateTimeWithTimeZone: 'DateTimeWithTimeZone',
DateTimeWithMilliSeconds: 'DateTimeWithMilliSeconds',
DateTimeWithSeconds: 'DateTimeWithSeconds',
UnixTimestamp: 'UnixTimestamp',
} as const;
export enum DateFormat {
DateTimeWithTimeZone = 'DateTimeWithTimeZone',
DateTimeWithMilliSeconds = 'DateTimeWithMilliSeconds',
DateTimeWithSeconds = 'DateTimeWithSeconds',
UnixTimestamp = 'UnixTimestamp',
}

/**
* Provide milliseconds, return a formatted string.
Expand Down

0 comments on commit 6bc1073

Please sign in to comment.