@brightspace-ui/intl 3.6.0 → 3.7.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/dateTime.js CHANGED
@@ -1128,10 +1128,24 @@ export function formatDateTime(date, options) {
1128
1128
 
1129
1129
  }
1130
1130
 
1131
- export function formatDateTimeFromTimestamp(timestamp, options) {
1131
+ function parseLocalDateTimeFromTimestamp(timestamp) {
1132
1132
  const utcDate = new Date(timestamp);
1133
1133
  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);
1134
+ if (!local) return utcDate;
1135
+ return new Date(local.year, local.month - 1, local.date, local.hours, local.minutes, local.seconds);
1136
+ }
1137
+
1138
+ export function formatDateTimeFromTimestamp(timestamp, options) {
1139
+ const date = parseLocalDateTimeFromTimestamp(timestamp);
1140
+ return formatDateTime(date, options);
1141
+ }
1142
+
1143
+ export function formatDateFromTimestamp(timestamp, options) {
1144
+ const date = parseLocalDateTimeFromTimestamp(timestamp);
1145
+ return formatDate(date, options);
1146
+ }
1147
+
1148
+ export function formatTimeFromTimestamp(timestamp, options) {
1149
+ const date = parseLocalDateTimeFromTimestamp(timestamp);
1150
+ return formatTime(date, options);
1137
1151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/intl",
3
- "version": "3.6.0",
3
+ "version": "3.7.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": {