@shopify/dates
Advanced tools
Comparing version 1.0.13 to 1.1.0
@@ -30,2 +30,3 @@ 'use strict'; | ||
var mapDeprecatedTimezones = require('./map-deprecated-timezones.js'); | ||
var format = require('./format.js'); | ||
var formatDate = require('./utilities/formatDate.js'); | ||
@@ -64,4 +65,5 @@ var timezone = require('./utilities/timezone.js'); | ||
exports.mapDeprecatedTimezones = mapDeprecatedTimezones.mapDeprecatedTimezones; | ||
exports.format = format.format; | ||
exports.formatDate = formatDate.formatDate; | ||
exports.memoizedGetDateTimeFormat = formatDate.memoizedGetDateTimeFormat; | ||
exports.getIanaTimeZone = timezone.getIanaTimeZone; |
@@ -27,2 +27,3 @@ export * from './apply-time-zone-offset'; | ||
export * from './utilities'; | ||
export * from './format'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@shopify/dates", | ||
"version": "1.0.13", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -50,3 +50,3 @@ "description": "Lightweight date operations library", | ||
}, | ||
"gitHead": "8bfa136b3968a7d509cd7d828b29cd143b98075c" | ||
"gitHead": "9d13dd8d53817efdb768147247d8ce9855ab7d8c" | ||
} |
@@ -34,2 +34,41 @@ # `@shopify/dates` | ||
### `format` | ||
Lighter replacement for [`format()` from the `moment` library](https://momentjs.com/docs/#/displaying/format/). | ||
Can output to any given locale / timezone (defaults to the system's locale & timezone). | ||
Handles a subset of the tokens `moment().format()` handles, namely the following: | ||
| | | | | ||
| -----------: | ---- | -------------------------------------- | | ||
| Month | M | 1 2 ... 11 12 | | ||
| | MM | 01 02 ... 11 12 | | ||
| | MMM | Jan Feb ... Nov Dec | | ||
| | MMMM | January February ... November December | | ||
| Day of Month | D | 1 2 ... 30 31 | | ||
| | DD | 01 02 ... 30 31 | | ||
| Day of Week | ddd | Sun Mon ... Fri Sat | | ||
| | dddd | Sunday Monday ... Friday Saturday | | ||
| Year | YY | 70 71 ... 29 30 | | ||
| | YYYY | 1970 1971 ... 2029 2030 | | ||
| Hour | H | 0 1 ... 22 23 | | ||
| | HH | 00 01 ... 22 23 | | ||
| | h | 1 2 ... 11 12 | | ||
| | hh | 01 02 ... 11 12 | | ||
| Minute | m | 0 1 ... 58 59 | | ||
| | mm | 00 01 ... 58 59 | | ||
| Second | s | 0 1 ... 58 59 | | ||
| | ss | 00 01 ... 58 59 | | ||
| AM/PM | A | AM PM | | ||
| | a | am pm | | ||
```ts | ||
import {format} from '@shopify/dates'; | ||
const date = new Date(2021, 0, 14, 13, 2, 3); | ||
const dateStr = format(date, 'YYYY-MM-DD h:mm:ss A'); // 2021-01-14 1:02:03 PM | ||
const date2 = new Date(Date.UTC(2021, 1, 1)); | ||
const dateStr2 = format(date, 'M/D/YY', 'UTC', 'en-US'); // 1/1/21 | ||
``` | ||
### `formatDate` | ||
@@ -36,0 +75,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
117087
161
1816
378