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

Validate time zone in quickDT prior to guessing offset #1575

Conversation

schleyfox
Copy link
Contributor

This is part of a series of PRs based on performance work we have done to
improve a use-case involving parsing/formatting hundreds of thousands of dates
where luxon was the bottleneck.

We validate the zone in the constructor anyway, but the tests missed a branch where we attempt to use an invalid zone to compute an offset, which will result in an exception. Zone#isValid is calculated at creation time (and checked in DateTime constructor already) so this will not degrade performance in the happy case.

We discovered this when shifting callsites to use DateTime.local from things that previously called through fromObject.

We validate the zone in the constructor anyway, but the tests missed a
branch where we attempt to use an invalid zone to compute an offset,
which will result in an exception. Zone#isValid is calculated at
creation time (and checked in DateTime constructor already) so this will
not degrade performance in the happy case.
Copy link

linux-foundation-easycla bot commented Jan 22, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: schleyfox / name: Ben Hughes (6072eba)

@schleyfox schleyfox marked this pull request as ready for review January 22, 2024 16:50
@icambron icambron merged commit f257940 into moment:master Jan 22, 2024
1 check passed
@icambron
Copy link
Member

Looks good, thanks!

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.

None yet

2 participants