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

Add user offset to help with guesses. #256

Merged

Conversation

timrwood
Copy link
Member

@timrwood timrwood commented Oct 7, 2015

This addresses the 1. Inspect Environment part of #220 (comment).

It loops over each month in the 4 years surrounding the current date and builds an array of OffsetAt objects for each time the offset changed. Within a month, it uses a binary search to find the exact minute the offset changed.

The number of lookups is fairly consistent across timezones. There are a minimum of 48 lookups (1 per month), and for each month that has a change in offset, only ~16 more lookups are needed to find the exact time of change. This results in ~180 lookups for timezones with DST, and 315 for a more complicated zone like Morocco.

This does not address 2. Broad Search, or 3. Narrow Search + Score, but those can be addressed in addZone and rebuildGuess respectively.

cc @mj1856

@timrwood timrwood mentioned this pull request Oct 7, 2015
Allow guesses to ignore cached values.
@timrwood
Copy link
Member Author

timrwood commented Nov 5, 2015

Merging this in to allow further progress on 2. Broad Search and 3. Narrow Search + Score.

timrwood added a commit that referenced this pull request Nov 5, 2015
@timrwood timrwood merged commit f36db89 into moment:guess-timezone Nov 5, 2015
@timrwood timrwood deleted the guess-timezone-user-offsets branch November 5, 2015 15:03
@mattjohnsonpint
Copy link
Contributor

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