@shopify/dates
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -5,8 +5,13 @@ # Changelog | ||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). | ||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||
and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | ||
--- | ||
<!-- ## [Unreleased] --> | ||
## Unreleased | ||
## [0.3.4] - 2020-03-13 | ||
### Added | ||
- Added `getIanaTimeZone` and exposed `memoizedGetDateTimeFormat` ([#1367](https://github.com/Shopify/quilt/pull/1367)) | ||
## [0.3.1] - 2020-02-27 | ||
@@ -16,7 +21,7 @@ | ||
- Allows `hour12: true` to be passed to `formatDate` [#1299](https://github.com/Shopify/quilt/pull/1299) | ||
- Allows `hour12: true` to be passed to `formatDate` ([#1299](https://github.com/Shopify/quilt/pull/1299)) | ||
## [0.3.0] - 2020-02-19 | ||
- Export the `formatDate` function so it can be used by other packages / projects, e.g. in `@shopify/react-i18n` | ||
- Export the `formatDate` function so it can be used by other packages / projects, e.g. in `@shopify/react-i18n` ([#1286](https://github.com/Shopify/quilt/pull/1286)) | ||
@@ -23,0 +28,0 @@ ## [0.2.13] - 2020-02-07 |
@@ -0,6 +1,8 @@ | ||
export declare function memoizedGetDateTimeFormat(locales?: string | string[], options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat; | ||
interface FormatDateOptions extends Intl.DateTimeFormatOptions { | ||
hourCycle?: string; | ||
} | ||
export declare function formatDate(date: Date, locales: string | string[], options?: FormatDateOptions): any; | ||
export declare function formatDate(date: Date, locales: string | string[], options?: FormatDateOptions): string; | ||
export declare function dateTimeFormatCacheKey(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; | ||
export {}; | ||
//# sourceMappingURL=formatDate.d.ts.map |
@@ -5,11 +5,12 @@ "use strict"; | ||
var intl = new Map(); | ||
var memoizedGetDateTimeFormat = function (locale, options) { | ||
var key = dateTimeFormatCacheKey(locale, options); | ||
function memoizedGetDateTimeFormat(locales, options) { | ||
var key = dateTimeFormatCacheKey(locales, options); | ||
if (intl.has(key)) { | ||
return intl.get(key); | ||
} | ||
var i = new Intl.DateTimeFormat(locale, options); | ||
var i = new Intl.DateTimeFormat(locales, options); | ||
intl.set(key, i); | ||
return i; | ||
}; | ||
} | ||
exports.memoizedGetDateTimeFormat = memoizedGetDateTimeFormat; | ||
var browserFeatureDetectionDate = Intl.DateTimeFormat('en', { | ||
@@ -39,3 +40,6 @@ hour: 'numeric', | ||
function dateTimeFormatCacheKey(locales, options) { | ||
return locales + "-" + JSON.stringify(options); | ||
if (options === void 0) { options = {}; } | ||
var localeKey = Array.isArray(locales) ? locales.sort().join('-') : locales; | ||
return localeKey + "-" + JSON.stringify(options); | ||
} | ||
exports.dateTimeFormatCacheKey = dateTimeFormatCacheKey; |
@@ -1,2 +0,3 @@ | ||
export { formatDate } from './formatDate'; | ||
export { formatDate, memoizedGetDateTimeFormat } from './formatDate'; | ||
export { getIanaTimeZone } from './timezone'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -5,1 +5,4 @@ "use strict"; | ||
exports.formatDate = formatDate_1.formatDate; | ||
exports.memoizedGetDateTimeFormat = formatDate_1.memoizedGetDateTimeFormat; | ||
var timezone_1 = require("./timezone"); | ||
exports.getIanaTimeZone = timezone_1.getIanaTimeZone; |
{ | ||
"name": "@shopify/dates", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Lightweight date operations library.", |
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
48732
81
689