@brightspace-ui/intl
Advanced tools
Comparing version 3.0.10 to 3.0.11
@@ -137,5 +137,5 @@ export const defaultLocale = 'en'; | ||
this.overrides = {}; | ||
this.timezone = {name: '', identifier: ''}; | ||
this.timezone = { name: '', identifier: '' }; | ||
this._listeners = []; | ||
this.oslo = {batch: null, collection: null, version: null}; | ||
this.oslo = { batch: null, collection: null, version: null }; | ||
} | ||
@@ -147,4 +147,4 @@ | ||
this.overrides = this._tryParseHtmlElemAttr('data-intl-overrides', {}); | ||
this.timezone = this._tryParseHtmlElemAttr('data-timezone', {name: '', identifier: ''}); | ||
this.oslo = this._tryParseHtmlElemAttr('data-oslo', {batch: null, collection: null, version: null}); | ||
this.timezone = this._tryParseHtmlElemAttr('data-timezone', { name: '', identifier: '' }); | ||
this.oslo = this._tryParseHtmlElemAttr('data-oslo', { batch: null, collection: null, version: null }); | ||
} | ||
@@ -162,5 +162,5 @@ | ||
} else if (mutation.attributeName === 'data-timezone') { | ||
this.timezone = this._tryParseHtmlElemAttr('data-timezone', {name: '', identifier: ''}); | ||
this.timezone = this._tryParseHtmlElemAttr('data-timezone', { name: '', identifier: '' }); | ||
} else if (mutation.attributeName === 'data-oslo') { | ||
this.oslo = this._tryParseHtmlElemAttr('data-oslo', {batch: null, collection: null, version: null}); | ||
this.oslo = this._tryParseHtmlElemAttr('data-oslo', { batch: null, collection: null, version: null }); | ||
} | ||
@@ -167,0 +167,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import {getDocumentLocaleSettings, getLanguage, merge} from './common.js'; | ||
import { getDocumentLocaleSettings, getLanguage, merge } from './common.js'; | ||
@@ -6,2 +6,183 @@ const hour24locales = ['da', 'de', 'es', 'fr', 'nl', 'pt', 'sv', 'tr', 'zh']; | ||
// leaving out the following since do not throw and have multiple possible offsets: AMT, AST, BST, CDT, CST, ECT, GST, IST, LHST, MST, PST, SST | ||
const timezoneOffsetMap = { | ||
'ACDT': '+1030', | ||
'ACST': '+0930', | ||
'ACWST': '+0845', | ||
'ADT': '-0300', | ||
'AEDT': '+1100', | ||
'AEST': '+1000', | ||
'AET': '+1000', | ||
'AFT': '+0430', | ||
'AKDT': '-0800', | ||
'AKST': '-0900', | ||
'ALMT': '+0600', | ||
'AMST': '-0300', | ||
'ANAT': '+1200', | ||
'AQTT': '+0500', | ||
'ART': '-0300', | ||
'AWST': '+0800', | ||
'AZOST': '+0000', | ||
'AZOT': '-0100', | ||
'AZT': '+0400', | ||
'BDT': '+0800', | ||
'BIOT': '+0600', | ||
'BIT': '-1200', | ||
'BOT': '-0400', | ||
'BRST': '-0200', | ||
'BRT': '-0300', | ||
'BTT': '+0600', | ||
'CAT': '+0200', | ||
'CCT': '+0630', | ||
'CEST': '+0200', | ||
'CET': '+0100', | ||
'CHADT': '+1345', | ||
'CHAST': '+1245', | ||
'CHOT': '+0800', | ||
'CHOST': '+0900', | ||
'CHST': '+1000', | ||
'CHUT': '+1000', | ||
'CIST': '-0800', | ||
'CIT': '+0800', | ||
'CKT': '-1000', | ||
'CLST': '-0300', | ||
'CLT': '-0400', | ||
'COST': '-0400', | ||
'COT': '-0500', | ||
'CT': '+0800', | ||
'CVT': '-0100', | ||
'CWST': '+0845', | ||
'CXT': '+0700', | ||
'DAVT': '+0700', | ||
'DDUT': '+1000', | ||
'DFT': '+0100', | ||
'EASST': '-0500', | ||
'EAST': '-0600', | ||
'EAT': '+0300', | ||
'EDT': '-0400', | ||
'EEST': '+0300', | ||
'EET': '+0200', | ||
'EGST': '+0000', | ||
'EGT': '-0100', | ||
'EIT': '+0900', | ||
'EST': '-0500', | ||
'FET': '+0300', | ||
'FJT': '+1200', | ||
'FKST': '-0300', | ||
'FKT': '-0400', | ||
'FNT': '-0200', | ||
'GALT': '-0600', | ||
'GAMT': '-0900', | ||
'GET': '+0400', | ||
'GFT': '-0300', | ||
'GILT': '+1200', | ||
'GIT': '-0900', | ||
'GMT': '+0000', | ||
'GYT': '-0400', | ||
'HDT': '-0900', | ||
'HAEC': '+0200', | ||
'HST': '-1000', | ||
'HKT': '+0800', | ||
'HMT': '+0500', | ||
'HOVST': '+0800', | ||
'HOVT': '+0700', | ||
'ICT': '+0700', | ||
'IDLW': '-1200', | ||
'IDT': '+0300', | ||
'IOT': '+0300', | ||
'IRDT': '+0430', | ||
'IRKT': '+0800', | ||
'IRST': '+0330', | ||
'JST': '+0900', | ||
'KALT': '+0200', | ||
'KGT': '+0600', | ||
'KOST': '+1100', | ||
'KRAT': '+0700', | ||
'KST': '+0900', | ||
'LINT': '+1400', | ||
'MAGT': '+1200', | ||
'MART': '-0930', | ||
'MAWT': '+0500', | ||
'MDT': '-0600', | ||
'MET': '+0100', | ||
'MEST': '+0200', | ||
'MHT': '+1200', | ||
'MIST': '+1100', | ||
'MIT': '-0930', | ||
'MMT': '+0630', | ||
'MSK': '+0300', | ||
'MUT': '+0400', | ||
'MVT': '+0500', | ||
'MYT': '+0800', | ||
'NCT': '+1100', | ||
'NDT': '-0230', | ||
'NFT': '+1100', | ||
'NOVT': '+0700', | ||
'NPT': '+0545', | ||
'NST': '-0330', | ||
'NT': '-0330', | ||
'NUT': '-1100', | ||
'NZDT': '+1300', | ||
'NZST': '+1200', | ||
'OMST': '+0600', | ||
'ORAT': '+0500', | ||
'PDT': '-0700', | ||
'PET': '-0500', | ||
'PETT': '+1200', | ||
'PGT': '+1000', | ||
'PHOT': '+1300', | ||
'PHT': '+0800', | ||
'PKT': '+0500', | ||
'PMDT': '-0200', | ||
'PMST': '-0300', | ||
'PONT': '+1100', | ||
'PYST': '-0300', | ||
'PYT': '-0400', | ||
'RET': '+0400', | ||
'ROTT': '-0300', | ||
'SAKT': '+1100', | ||
'SAMT': '+0400', | ||
'SAST': '+0200', | ||
'SBT': '+1100', | ||
'SCT': '+0400', | ||
'SDT': '-1000', | ||
'SGT': '+0800', | ||
'SLST': '+0530', | ||
'SRET': '+1100', | ||
'SRT': '-0300', | ||
'SYOT': '+0300', | ||
'TAHT': '-1000', | ||
'THA': '+0700', | ||
'TFT': '+0500', | ||
'TJT': '+0500', | ||
'TKT': '+1300', | ||
'TLT': '+0900', | ||
'TMT': '+0500', | ||
'TRT': '+0300', | ||
'TOT': '+1300', | ||
'TVT': '+1200', | ||
'ULAST': '+0900', | ||
'ULAT': '+0800', | ||
'UTC': '+0000', | ||
'UYST': '-0200', | ||
'UYT': '-0300', | ||
'UZT': '+0500', | ||
'VET': '-0400', | ||
'VLAT': '+1000', | ||
'VOLT': '+0400', | ||
'VOST': '+0600', | ||
'VUT': '+1100', | ||
'WAKT': '+1200', | ||
'WAST': '+0200', | ||
'WAT': '+0100', | ||
'WEST': '+0100', | ||
'WET': '+0000', | ||
'WIT': '+0700', | ||
'WGST': '-0200', | ||
'WGT': '-0300', | ||
'WST': '+0800', | ||
'YAKT': '+0900', | ||
'YEKT': '+0500' | ||
}; | ||
function buildDayPeriodRe(part) { | ||
@@ -233,10 +414,20 @@ let re = ''; | ||
}; | ||
const timezone = formatDateString(dateDate).split(' ')[2]; | ||
const dateString = getDateStringWithTimezone(datePrePad, timezone); | ||
const parsedDateString = new Date(Date.parse(dateString)); | ||
let timezone = formatDateString(dateDate).split(' ')[2]; | ||
let dateString = getDateStringWithTimezone(datePrePad, timezone); | ||
let parsedDateString = new Date(Date.parse(dateString)); | ||
if (isNaN(parsedDateString.getTime())) { | ||
timezone = timezoneOffsetMap[timezone]; | ||
dateString = getDateStringWithTimezone(datePrePad, timezone); | ||
parsedDateString = new Date(Date.parse(dateString)); | ||
} | ||
// run again in case of DST (e.g., if timezone is CST for dateDate but local time is after CST is over, timezone is incorrect) | ||
const utcCorrectedTimezone = formatDateString(parsedDateString).split(' ')[2]; | ||
const dateStringInTimezone = getDateStringWithTimezone(datePrePad, utcCorrectedTimezone); | ||
const utcCorrectedDate = new Date(Date.parse(dateStringInTimezone)); | ||
let utcCorrectedTimezone = formatDateString(parsedDateString).split(' ')[2]; | ||
let dateStringInTimezone = getDateStringWithTimezone(datePrePad, utcCorrectedTimezone); | ||
let utcCorrectedDate = new Date(Date.parse(dateStringInTimezone)); | ||
if (isNaN(utcCorrectedDate.getTime())) { | ||
utcCorrectedTimezone = timezoneOffsetMap[utcCorrectedTimezone]; | ||
dateStringInTimezone = getDateStringWithTimezone(datePrePad, utcCorrectedTimezone); | ||
utcCorrectedDate = new Date(Date.parse(dateStringInTimezone)); | ||
} | ||
@@ -474,3 +665,3 @@ return { | ||
}, | ||
dayPeriods: {am: dayPeriods[0], pm: dayPeriods[1]} | ||
dayPeriods: { am: dayPeriods[0], pm: dayPeriods[1] } | ||
} | ||
@@ -477,0 +668,0 @@ }; |
@@ -1,3 +0,3 @@ | ||
import {formatNumber} from './number.js'; | ||
import {getLanguage, validateFormatValue} from './common.js'; | ||
import { formatNumber } from './number.js'; | ||
import { getLanguage, validateFormatValue } from './common.js'; | ||
@@ -66,6 +66,6 @@ export function getFileSizeDescriptor() { | ||
const fileSizeUnits = [ | ||
{unit: descriptor.gigabyte, num: Math.pow(1024, 3)}, | ||
{unit: descriptor.megabyte, num: Math.pow(1024, 2)}, | ||
{unit: descriptor.kilobyte, num: 1024}, | ||
{unit: descriptor.bytes, num: 1} | ||
{ unit: descriptor.gigabyte, num: Math.pow(1024, 3) }, | ||
{ unit: descriptor.megabyte, num: Math.pow(1024, 2) }, | ||
{ unit: descriptor.kilobyte, num: 1024 }, | ||
{ unit: descriptor.bytes, num: 1 } | ||
]; | ||
@@ -72,0 +72,0 @@ let formatUnit, size; |
{ | ||
"name": "@brightspace-ui/intl", | ||
"version": "3.0.10", | ||
"version": "3.0.11", | ||
"description": "Internationalization APIs for number, date, time and file size formatting and parsing in D2L Brightspace.", | ||
@@ -43,3 +43,3 @@ "main": "lib/number.js", | ||
"eslint": "^7", | ||
"eslint-config-brightspace": "^0.9", | ||
"eslint-config-brightspace": "^0.10", | ||
"eslint-plugin-html": "^6", | ||
@@ -46,0 +46,0 @@ "eslint-plugin-sort-class-members": "^1", |
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
58959
1286