-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Typed timestamp utility #33512
base: main
Are you sure you want to change the base?
Conversation
|
||
export function asTimestamp(input: unknown): Timestamp | null { | ||
if (input instanceof Date) { | ||
const date = DateTime.fromJSDate(input, { zone: 'UTC' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we change the timezone to a probably wrong value here? or is datetime correctly converting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's converted from whatever timezone the original value is, to the UTC
return millisDate.toISO() as Timestamp; | ||
} | ||
|
||
const secondsDate = DateTime.fromSeconds(input, { zone: 'UTC' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If some datasource is capable of providing timestamp in the millisecond format, I could imagine it's done in the seconds format as well
Changes
Context
Documentation (please check one with an [x])
How I've tested my work (please select one)
I have verified these changes via: