Skip to content
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

fix(datetime): account for 30 and 45 minute timezones when getting current date #25120

Merged
merged 3 commits into from
Apr 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion core/src/components/datetime/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@ export const getToday = () => {
* there was a net change of zero hours from the
* local date.
*/
date.setHours(date.getHours() - tzOffset / 60);
const adjustedHours = date.getHours() - tzOffset / 60;

/**
* Some timezones have include minute adjustments
liamdebeasi marked this conversation as resolved.
Show resolved Hide resolved
* such as 30 or 45 minutes.
* Example: India Standard Time
* Timezone offset: -330 = -5.5 hours.
*
* As a result, we need to make sure we also
* increment the minutes as well.
* List of timezones with 30 and 45 minute timezones:
* https://www.timeanddate.com/time/time-zones-interesting.html
*/
const minutesRemainder = adjustedHours % 1;
const adjustedMinutes = date.getMinutes() + minutesRemainder * 60;
date.setHours(adjustedHours);
date.setMinutes(adjustedMinutes);

return date.toISOString();
};

Expand Down