@brightspace-ui/intl
Advanced tools
Comparing version 3.0.7 to 3.0.8
@@ -35,2 +35,15 @@ import {getDocumentLocaleSettings, getLanguage, merge} from './common.js'; | ||
function getDateStringWithTimezone(date, timezone) { | ||
let dateString = `${date.month}/${date.date}/${date.year}, ${date.hours}:${date.minutes}:${date.seconds} ${timezone}`; | ||
if (timezone.includes('-') || timezone.includes('+')) { | ||
const re = /([A-Z]{3})(\+|-)([0-9]{1,2}):([0-9]{2})/; | ||
const match = timezone.match(re); | ||
if (match && match.length === 5) { | ||
// YYYY-MM-DDTHH:mm:ss(+|-)HH:MM | ||
dateString = `${date.year}-${date.month}-${date.date}T${date.hours}:${date.minutes}:${date.seconds}${match[2]}${prePadByZero(match[3], 2)}:${prePadByZero(match[4], 2)}`; | ||
} | ||
} | ||
return dateString; | ||
} | ||
function getParts() { | ||
@@ -212,4 +225,12 @@ | ||
const dateDate = new Date(date.year, date.month - 1, date.date, date.hours, date.minutes, date.seconds); | ||
const datePrePad = { | ||
year: date.year, | ||
month: prePadByZero(date.month, 2), | ||
date: prePadByZero(date.date, 2), | ||
hours: prePadByZero(date.hours, 2), | ||
minutes: prePadByZero(date.minutes, 2), | ||
seconds: prePadByZero(date.seconds, 2) | ||
}; | ||
const timezone = formatDateString(dateDate).split(' ')[2]; | ||
const dateString = `${date.month}/${date.date}/${date.year}, ${date.hours}:${date.minutes}:${date.seconds} ${timezone}`; | ||
const dateString = getDateStringWithTimezone(datePrePad, timezone); | ||
const parsedDateString = new Date(Date.parse(dateString)); | ||
@@ -219,3 +240,3 @@ | ||
const utcCorrectedTimezone = formatDateString(parsedDateString).split(' ')[2]; | ||
const dateStringInTimezone = `${date.month}/${date.date}/${date.year}, ${date.hours}:${date.minutes}:${date.seconds} ${utcCorrectedTimezone}`; | ||
const dateStringInTimezone = getDateStringWithTimezone(datePrePad, utcCorrectedTimezone); | ||
const utcCorrectedDate = new Date(Date.parse(dateStringInTimezone)); | ||
@@ -222,0 +243,0 @@ |
{ | ||
"name": "@brightspace-ui/intl", | ||
"version": "3.0.7", | ||
"version": "3.0.8", | ||
"description": "Internationalization APIs for number, date, time and file size formatting and parsing in D2L Brightspace.", | ||
@@ -5,0 +5,0 @@ "main": "lib/number.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53993
1096