-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
fix(date-picker): ignore timezone in date-picker
Showing
2 changed files
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Formats the date to an ISO string where the timezone of date is ignored before conversion to UTC. | ||
* | ||
* This is useful for date-selectors where we get information with timezone information, | ||
* but we are just interested in the date itself, and don't want the time to be adjusted when converting to UTC. | ||
* @param {Date} date - the date to convert to an UTC ISO string | ||
* @returns date formatted as ISO string without timezone information | ||
*/ | ||
export const getISOFormatLocalTimestamp = date => | ||
new Date(date.getTime() - date.getTimezoneOffset() * 60000) | ||
.toISOString() |