Skip to content

Commit

Permalink
fix : utcToZonedTime returns next day when time matches offset
Browse files Browse the repository at this point in the history
  • Loading branch information
hyyan committed Feb 6, 2020
1 parent b0d5ad0 commit 22816a4
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions src/_lib/tzTokenizeDate/index.js
Expand Up @@ -43,16 +43,32 @@ function hackyOffset(dtf, date) {
var dtfCache = {}
function getDateTimeFormat(timeZone) {
if (!dtfCache[timeZone]) {
dtfCache[timeZone] = new Intl.DateTimeFormat('en-US', {
hour12: false,
timeZone: timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
})
// @see https://github.com/marnusw/date-fns-tz/issues/38
var isIE11 = !!window.MSInputMethodContext && !!document.documentMode
if (isIE11) {
dtfCache[timeZone] = new Intl.DateTimeFormat('en-US', {
hour12: false,
timeZone: timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
})
} else {
dtfCache[timeZone] = new Intl.DateTimeFormat('en-US', {
// hour12: false,
hourCycle: 'h23',
timeZone: timeZone,
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
})
}
}
return dtfCache[timeZone]
}

0 comments on commit 22816a4

Please sign in to comment.