Skip to content

Commit

Permalink
Use Intl API for guessing when available
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint committed Jan 15, 2016
1 parent 52d896c commit 49e4c66
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions moment-timezone.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,15 @@
}

function rebuildGuess () {

// use Intl API when available and returning valid time zone
if (Intl && isFunction(Intl.DateTimeFormat)) {
var zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (zone && (zone.indexOf("/") > -1 || zone === 'UTC')) {
return zone;
}
}

var offsets = userOffsets(),
offsetsLength = offsets.length,
guesses = guessesForUserOffsets(offsets),
Expand Down

0 comments on commit 49e4c66

Please sign in to comment.