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 differences in duration #2353

Merged
merged 2 commits into from
Sep 27, 2024
Merged

Conversation

laurakwhit
Copy link
Contributor

Description & motivation 💭

The toSeconds util uses intervalToDuration which is expecting an interval object (consisting of two Dates) to be passed as the parameter and therefore it utilizes the Date constructor. new Date() creates a datetime in the client timezone which was causing differences in duration (e.g. timer duration ⬇️ )
Screenshot 2024-09-26 at 3 31 50 PM
for different users based on what their system timezone was set to.

This PR passes two Dates based on UTC instead of relying on the client timezone in instances where intervalToDuration is being determined based on seconds.

Screenshots (if applicable) 📸

Design Considerations 🎨

Testing 🧪

If system settings are set to PDT

intervalToDuration({ start: 0, end: (2652361 * 1000) })

will return { months: 1, hours: 7, minutes: 853, seconds: 102419 } and

intervalToDuration({ start: new Date(Date.UTC(0, 0, 0, 0, 0, 0)), end: new Date(Date.UTC(0, 0, 0, 0, 0, 2652361))})

will return { days: 30, hours: 16, minutes: 46, seconds: 1 }

How was this tested 👻

  • Manual testing
  • E2E tests added
  • Unit tests added

Steps for others to test: 🚶🏽‍♂️🚶🏽‍♀️

Checklists

Draft Checklist

Merge Checklist

Issue(s) closed

DT-2484

Docs

Any docs updates needed?

Copy link

vercel bot commented Sep 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
holocene ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2024 9:44pm

@Alex-Tideman
Copy link
Contributor

Incredible detective work!

@laurakwhit laurakwhit merged commit 0106d97 into main Sep 27, 2024
14 checks passed
@laurakwhit laurakwhit deleted the DT-2484-fix-differences-in-duration branch September 27, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants