New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@brightspace-ui/intl

Package Overview
Dependencies
Maintainers
3
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brightspace-ui/intl - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

4

lib/common.js
export const defaultLocale = 'en';
export const supportedBaseLocales = ['ar', 'da', 'de', 'en', 'es', 'fr', 'ja', 'ko', 'nl', 'pt', 'sv', 'tr', 'zh'];
export const supportedBaseLocales = ['ar', 'cy', 'da', 'de', 'en', 'es', 'fr', 'ja', 'ko', 'nl', 'pt', 'sv', 'tr', 'zh'];
export const supportedLocales = [
'ar-sa',
'cy-gb',
'da-dk',

@@ -10,2 +11,3 @@ 'de-de',

'en-gb',
'es-es',
'es-mx',

@@ -12,0 +14,0 @@ 'fr-ca',

import { getDocumentLocaleSettings, getLanguage, merge } from './common.js';
const hour24locales = ['da', 'de', 'es', 'fr', 'nl', 'pt', 'sv', 'tr', 'zh'];
const mondayFirstDayLocales = ['da', 'de', 'fr', 'nl', 'sv', 'tr'];
const hour24locales = ['cy', 'da', 'de', 'es', 'fr', 'nl', 'pt', 'sv', 'tr', 'zh'];
const mondayFirstDayLocales = ['cy', 'da', 'de', 'fr', 'nl', 'sv', 'tr'];

@@ -349,2 +349,74 @@ // timezone abbreviations and offsets from https://www.timeanddate.com/time/zones/

function getParts() {
const descriptor = getDateTimeDescriptor();
const result = [];
const separator = getSeparator();
const parts = descriptor.formats.dateFormats.short.split(separator);
for (var i = 0; i < parts.length; i++) {
var part = parts[i].trim();
switch (part) {
case 'dd':
case 'd':
result.push('d');
break;
case 'MM':
case 'M':
result.push('M');
break;
case 'yyyy':
result.push('yyyy');
break;
}
}
if (result.length !== 3) {
return ['M', 'd', 'yyyy'];
}
return result;
}
const reSeparator = new RegExp('\\W');
function getSeparator() {
const descriptor = getDateTimeDescriptor();
const match = reSeparator.exec(descriptor.formats.dateFormats.short);
if (match !== null) {
return match[0];
}
return '/';
}
function getTimeFormat(hour24, language, baseLanguage) {
if (hour24 && baseLanguage === 'fr') {
return 'HH\' h \'mm';
}
let timeFormat = hour24 ? 'HH:mm' : 'h:mm';
// non-zero padded 24-hour clocks and zero-padded 12-hour clocks
if (hour24 && (baseLanguage === 'ja' || language === 'pt-br' || (baseLanguage === 'zh' && language !== 'zh-tw'))) {
timeFormat = 'H:mm';
} else if (!hour24 && language === 'zh-tw') {
timeFormat = 'hh:mm';
}
if (!hour24) {
// AM/PM before vs. after
if (baseLanguage === 'ko' || baseLanguage === 'zh') {
timeFormat = `tt ${timeFormat}`;
} else {
timeFormat = `${timeFormat} tt`;
}
}
return timeFormat;
}
function getTimezoneFromDuplicatedAbbreviation(abbrTimezone) {

@@ -494,74 +566,2 @@ const longTimezone = getDocumentLocaleSettings().timezone.identifier;

function getParts() {
const descriptor = getDateTimeDescriptor();
const result = [];
const separator = getSeparator();
const parts = descriptor.formats.dateFormats.short.split(separator);
for (var i = 0; i < parts.length; i++) {
var part = parts[i].trim();
switch (part) {
case 'dd':
case 'd':
result.push('d');
break;
case 'MM':
case 'M':
result.push('M');
break;
case 'yyyy':
result.push('yyyy');
break;
}
}
if (result.length !== 3) {
return ['M', 'd', 'yyyy'];
}
return result;
}
const reSeparator = new RegExp('\\W');
function getSeparator() {
const descriptor = getDateTimeDescriptor();
const match = reSeparator.exec(descriptor.formats.dateFormats.short);
if (match !== null) {
return match[0];
}
return '/';
}
function getTimeFormat(hour24, language, baseLanguage) {
if (hour24 && baseLanguage === 'fr') {
return 'HH\' h \'mm';
}
let timeFormat = hour24 ? 'HH:mm' : 'h:mm';
// non-zero padded 24-hour clocks and zero-padded 12-hour clocks
if (hour24 && (baseLanguage === 'ja' || language === 'pt-br' || (baseLanguage === 'zh' && language !== 'zh-tw'))) {
timeFormat = 'H:mm';
} else if (!hour24 && language === 'zh-tw') {
timeFormat = 'hh:mm';
}
if (!hour24) {
// AM/PM before vs. after
if (baseLanguage === 'ko' || baseLanguage === 'zh') {
timeFormat = `tt ${timeFormat}`;
} else {
timeFormat = `${timeFormat} tt`;
}
}
return timeFormat;
}
function isDateValid(year, month, day) {

@@ -644,10 +644,2 @@

export function convertUTCToLocalDateTime(date) {
if (!getDocumentLocaleSettings().timezone.identifier) {
return date;
}
const utcDate = new Date(Date.UTC(date.year, date.month - 1, date.date, date.hours, date.minutes, date.seconds));
return convertJsDateToLocalDateTime(utcDate) || date;
}
export function convertLocalToUTCDateTime(date) {

@@ -696,2 +688,10 @@ if (!getDocumentLocaleSettings().timezone.identifier) {

export function convertUTCToLocalDateTime(date) {
if (!getDocumentLocaleSettings().timezone.identifier) {
return date;
}
const utcDate = new Date(Date.UTC(date.year, date.month - 1, date.date, date.hours, date.minutes, date.seconds));
return convertJsDateToLocalDateTime(utcDate) || date;
}
export function getDateTimeDescriptor() {

@@ -745,2 +745,14 @@

break;
case 'cy':
dateFormats = ['dddd, d MMMM yyyy', 'dd MMMM yyyy', 'dd/MM/yyyy', 'MMMM yyyy', 'd MMMM', 'd MMM'];
months = [
['Ionawr', 'Chwefror', 'Mawrth', 'Ebrill', 'Mai', 'Mehefin', 'Gorffennaf', 'Awst', 'Medi', 'Hydref', 'Tachwedd', 'Rhagfyr'],
['Ion', 'Chwe', 'Maw', 'Ebr', 'Mai', 'Meh', 'Gor', 'Awst', 'Medi', 'Hyd', 'Tach', 'Rhag']
];
days = [
['Dydd Sul', 'Dydd Llun', 'Dydd Mawrth', 'Dydd Mercher', 'Dydd Iau', 'Dydd Gwener', 'Dydd Sadwrn'],
['Sul', 'Llun', 'Maw', 'Mer', 'Iau', 'Gwe', 'Sad'],
['Su', 'Ll', 'Ma', 'Me', 'Ia', 'Gw', 'Sa']
];
break;
case 'da':

@@ -771,3 +783,3 @@ dateFormats = ['dddd \'den\' d. MMMM yyyy', 'd. MMM. yyyy', 'dd.MM.yyyy', 'MMMM yyyy', 'd. MMMM', 'd. MMM'];

case 'es':
dateFormats = ['dddd d\' de \'MMMM\' de \'yyyy', 'd\' de \'MMMM\' de \'yyyy', 'd/M/yyyy', 'MMMM yyyy', 'd\' de \'MMMM', 'd\' de \'MMM'];
dateFormats = ['dddd d\' de \'MMMM\' de \'yyyy', 'd\' de \'MMMM\' de \'yyyy', 'dd/MM/yyyy', 'MMMM yyyy', 'd\' de \'MMMM', 'd\' de \'MMM'];
dayPeriods = ['a. m.', 'p. m.'];

@@ -873,5 +885,2 @@ months = [

break;
case 'es-mx':
dateFormats[2] = 'dd/MM/yyyy';
break;
case 'fr-ca':

@@ -878,0 +887,0 @@ dateFormats[1] = 'MMM d yyyy';

@@ -32,2 +32,5 @@ import { formatNumber } from './number.js';

break;
case 'cy':
val.bytes = val.byte = 'beit';
break;
case 'fr':

@@ -34,0 +37,0 @@ val.gigabyte = 'Go';

@@ -119,2 +119,3 @@ import {

switch (baseLanguage) {
case 'es':
case 'ja':

@@ -155,4 +156,2 @@ case 'pt':

groupSymbol = ',';
percentPattern = '{number}%';
percentNegativePattern = '-{number}%';
break;

@@ -159,0 +158,0 @@ }

{
"name": "@brightspace-ui/intl",
"version": "3.2.0",
"version": "3.3.0",
"description": "Internationalization APIs for number, date, time and file size formatting and parsing in D2L Brightspace.",

@@ -38,7 +38,8 @@ "main": "lib/number.js",

"devDependencies": {
"babel-eslint": "^10",
"@babel/core": "^7",
"@babel/eslint-parser": "^7",
"chai": "^4",
"concurrently": "^5",
"concurrently": "^6",
"eslint": "^7",
"eslint-config-brightspace": "^0.11",
"eslint-config-brightspace": "^0.13",
"eslint-plugin-html": "^6",

@@ -45,0 +46,0 @@ "eslint-plugin-sort-class-members": "^1",

@@ -178,4 +178,2 @@ # intl

**These are a work in progress and are not ready for usage yet**
To convert an object containing a UTC date to an object containing a local date corresponding to the `data-timezone` attribute:

@@ -182,0 +180,0 @@ ```javascript

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc