@brightspace-ui/intl 3.6.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -110,6 +110,30 @@ const dateString = formatDateTimeFromTimestamp(
110
110
  Options are the same as for `formatDateTime`; this method converts the timestamp to a `Date` in the user's
111
111
  configured time zone, then returns the results of passing this date to `formatDateTime`.
112
112
 
113
+ To format a **timestamp** as a date only:
114
+
115
+ ```javascript
116
+ const dateString = formatDateFromTimestamp(
117
+ 1607097863123,
118
+ [options]
119
+ );
120
+ ```
121
+
122
+ Options are the same as for `formatDate`; this method converts the timestamp to a `Date` in the user's
123
+ configured time zone, then returns the results of passing this date to `formatDate`.
124
+
125
+ To format a **timestamp** as a time only:
126
+
127
+ ```javascript
128
+ const timeString = formatTimeFromTimestamp(
129
+ 1607097863123,
130
+ [options]
131
+ );
132
+ ```
133
+
134
+ Options are the same as for `formatTime`; this method converts the timestamp to a `Date` in the user's
135
+ configured time zone, then returns the results of passing this date to `formatTime`.
136
+
113
137
  To format a **date only** (without the time portion), use `formatDate`:
114
138
 
115
139
  ```javascript
package/lib/common.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export const defaultLocale = 'en';
2
- export const supportedBaseLocales = ['ar', 'cy', 'da', 'de', 'en', 'es', 'fr', 'ja', 'ko', 'nl', 'pt', 'sv', 'tr', 'zh'];
2
+ export const supportedBaseLocales = ['ar', 'cy', 'da', 'de', 'en', 'es', 'fr', 'hi', 'ja', 'ko', 'nl', 'pt', 'sv', 'tr', 'zh'];
3
3
  export const supportedLocales = [
4
4
  'ar-sa',
5
5
  'cy-gb',
@@ -13,6 +13,7 @@ export const supportedLocales = [
13
13
  'fr-ca',
14
14
  'fr-fr',
15
15
  'fr-on',
16
+ 'hi-in',
16
17
  'ja-jp',
17
18
  'ko-kr',
18
19
  'nl-nl',
package/lib/dateTime.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getDocumentLocaleSettings, getLanguage, merge } from './common.js';
2
2
 
3
3
  const hour24locales = ['cy', 'da', 'de', 'es', 'fr', 'nl', 'pt', 'sv', 'tr', 'zh'];
4
- const mondayFirstDayLocales = ['cy', 'da', 'de', 'fr', 'nl', 'sv', 'tr'];
4
+ const mondayFirstDayLocales = ['cy', 'da', 'de', 'fr', 'hi', 'nl', 'sv', 'tr'];
5
5
 
6
6
  // timezone abbreviations and offsets from https://www.timeanddate.com/time/zones/
7
7
  const timezoneOffsetMap = {
@@ -788,7 +788,7 @@ export function getDateTimeDescriptor() {
788
788
  ];
789
789
  break;
790
790
  case 'fr':
791
- dateFormats = ['dddd\' le \'d MMMM yyyy', 'd MMM yyyy', 'dd/MM/yyyy', 'MMMM yyyy', 'd MMMM', 'd MMM'];
791
+ dateFormats = ['dddd d MMMM yyyy', 'd MMM yyyy', 'dd/MM/yyyy', 'MMMM yyyy', 'd MMMM', 'd MMM'];
792
792
  months = [
793
793
  ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
794
794
  ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.']
@@ -799,6 +799,19 @@ export function getDateTimeDescriptor() {
799
799
  ['D', 'L', 'M', 'M', 'J', 'V', 'S']
800
800
  ];
801
801
  break;
802
+ case 'hi':
803
+ dateFormats = ['dddd, d MMMM yyyy', 'd MMMM yyyy', 'dd-MM-yyyy', 'MMMM yyyy', 'd MMMM', 'd MMM'];
804
+ dayPeriods = ['पूर्वाह्न', 'अपराह्न'];
805
+ months = [
806
+ ['जनवरी', 'फरवरी', 'मार्च', 'अप्रैल', 'मई', 'जून', 'जुलाई', 'अगस्त', 'सितंबर', 'अक्टूबर', 'नवंबर', 'दिसंबर'],
807
+ ['जन', 'फर', 'मार्च', 'अप्रैल', 'मई', 'जून', 'जुलाई', 'अग', 'सितं', 'अक्टू', 'नवं', 'दिसं']
808
+ ];
809
+ days = [
810
+ ['रविवार', 'सोमवार', 'मंगलवार', 'बुधवार', 'गुरूवार', 'शुक्रवार', 'शनिवार'],
811
+ ['रवि', 'सोम', 'मंगल', 'बुध', 'गुरु', 'शुक्र', 'शनि'],
812
+ ['र', 'सो', 'मं', 'बु', 'गु', 'शु', 'श']
813
+ ];
814
+ break;
802
815
  case 'ja':
803
816
  dateFormats = ['yyyy年M月d日', 'yyyy年M月d日', 'yyyy/MM/dd', 'yyyy年M月', 'M月d日', 'M月d日'];
804
817
  dayPeriods = ['午前', '午後'];
@@ -877,13 +890,18 @@ export function getDateTimeDescriptor() {
877
890
  dateFormats = ['dddd, d MMMM yyyy', 'dd MMMM yyyy', 'dd/MM/yyyy', 'MMMM yyyy', 'd MMMM', 'd MMM'];
878
891
  break;
879
892
  case 'fr-ca':
880
- case 'fr-on':
881
893
  dateFormats[1] = 'MMM d yyyy';
882
894
  dateFormats[2] = 'yyyy-MM-dd';
883
895
  dateFormats[4] = 'MMMM d';
884
896
  dateFormats[5] = 'MMM d';
885
897
  firstDayOfWeek = 0;
886
898
  break;
899
+ case 'fr-on':
900
+ dateFormats[0] = 'dddd\' le \'d MMMM yyyy';
901
+ dateFormats[1] = 'MMM d yyyy';
902
+ dateFormats[2] = 'yyyy-MM-dd';
903
+ firstDayOfWeek = 0;
904
+ break;
887
905
  case 'zh-tw':
888
906
  days[0] = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
889
907
  break;
@@ -1128,10 +1146,24 @@ export function formatDateTime(date, options) {
1128
1146
 
1129
1147
  }
1130
1148
 
1131
- export function formatDateTimeFromTimestamp(timestamp, options) {
1149
+ function parseLocalDateTimeFromTimestamp(timestamp) {
1132
1150
  const utcDate = new Date(timestamp);
1133
1151
  const local = convertJsDateToLocalDateTime(utcDate);
1134
- if (!local) return formatDateTime(utcDate, options);
1135
- const localDate = new Date(local.year, local.month - 1, local.date, local.hours, local.minutes, local.seconds);
1136
- return formatDateTime(localDate, options);
1152
+ if (!local) return utcDate;
1153
+ return new Date(local.year, local.month - 1, local.date, local.hours, local.minutes, local.seconds);
1154
+ }
1155
+
1156
+ export function formatDateTimeFromTimestamp(timestamp, options) {
1157
+ const date = parseLocalDateTimeFromTimestamp(timestamp);
1158
+ return formatDateTime(date, options);
1159
+ }
1160
+
1161
+ export function formatDateFromTimestamp(timestamp, options) {
1162
+ const date = parseLocalDateTimeFromTimestamp(timestamp);
1163
+ return formatDate(date, options);
1164
+ }
1165
+
1166
+ export function formatTimeFromTimestamp(timestamp, options) {
1167
+ const date = parseLocalDateTimeFromTimestamp(timestamp);
1168
+ return formatTime(date, options);
1137
1169
  }
package/lib/fileSize.js CHANGED
@@ -39,6 +39,10 @@ export function getFileSizeDescriptor() {
39
39
  val.bytes = 'octets';
40
40
  val.byte = 'octet';
41
41
  break;
42
+ case 'hi':
43
+ val.bytes = 'बाइट्स';
44
+ val.byte = 'बाइट';
45
+ break;
42
46
  case 'ja':
43
47
  val.bytes = val.byte = 'バイト';
44
48
  break;
package/lib/number.js CHANGED
@@ -110,6 +110,7 @@ export function getNumberDescriptor() {
110
110
  let percentNegativePattern = '-{number} %';
111
111
  switch (baseLanguage) {
112
112
  case 'es':
113
+ case 'hi':
113
114
  case 'ja':
114
115
  case 'pt':
115
116
  case 'zh':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/intl",
3
- "version": "3.6.0",
3
+ "version": "3.9.0",
4
4
  "description": "Internationalization APIs for number, date, time and file size formatting and parsing in D2L Brightspace.",
5
5
  "main": "lib/number.js",
6
6
  "scripts": {
@@ -38,13 +38,13 @@
38
38
  "@babel/core": "^7",
39
39
  "@babel/eslint-parser": "^7",
40
40
  "chai": "^4",
41
- "concurrently": "^6",
42
- "eslint": "^7",
41
+ "concurrently": "^7",
42
+ "eslint": "^8",
43
43
  "eslint-config-brightspace": "^0.16",
44
44
  "eslint-plugin-html": "^6",
45
45
  "eslint-plugin-sort-class-members": "^1",
46
46
  "http-server": "^14.0",
47
47
  "mocha": "^9",
48
- "mocha-headless-chrome": "^3"
48
+ "mocha-headless-chrome": "^4"
49
49
  }
50
50
  }