@shopify/dates
Advanced tools
Comparing version 0.2.13-beta.fixchrome80 to 0.2.13-fixmemoryleak-beta.1
@@ -9,6 +9,2 @@ # Changelog | ||
## [Unreleased] | ||
- Move Chrome 80 bug fix outside of gaurding if | ||
## [0.2.12] - 2020-02-07 | ||
@@ -15,0 +11,0 @@ |
interface FormatDateOptions extends Intl.DateTimeFormatOptions { | ||
hourCycle?: string; | ||
} | ||
export declare function formatDate(date: Date, locales: string | string[], options?: FormatDateOptions): string; | ||
export declare function formatDate(date: Date, locales: string | string[], options?: FormatDateOptions): any; | ||
export {}; | ||
//# sourceMappingURL=formatDate.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var function_enhancers_1 = require("@shopify/function-enhancers"); | ||
var memoizedGetDateTimeFormat = function_enhancers_1.memoize(getDateTimeFormat, dateTimeFormatCacheKey); | ||
var intl = new Map(); | ||
var memoizedGetDateTimeFormat = function (locale, options) { | ||
var key = dateTimeFormatCacheKey(locale, options); | ||
if (intl.has(key)) { | ||
return intl.get(key); | ||
} | ||
var i = new Intl.DateTimeFormat(locale, options); | ||
intl.set(key, i); | ||
return i; | ||
}; | ||
function formatDate(date, locales, options) { | ||
if (options === void 0) { options = {}; } | ||
if (options.hour12 != null && options.hourCycle != null) { | ||
options.hour12 = undefined; | ||
options.hourCycle = 'h23'; | ||
} | ||
// Etc/GMT+12 is not supported in most browsers and there is no equivalent fallback | ||
@@ -13,14 +25,7 @@ if (options.timeZone != null && options.timeZone === 'Etc/GMT+12') { | ||
} | ||
if (options.hour12 != null) { | ||
options.hour12 = undefined; | ||
options.hourCycle = 'h23'; | ||
} | ||
return memoizedGetDateTimeFormat(locales, options).format(date); | ||
} | ||
exports.formatDate = formatDate; | ||
function getDateTimeFormat(locales, options) { | ||
return Intl.DateTimeFormat(locales, options); | ||
} | ||
function dateTimeFormatCacheKey(locales, options) { | ||
return locales + "-" + JSON.stringify(options); | ||
} |
{ | ||
"name": "@shopify/dates", | ||
"version": "0.2.13-beta.fixchrome80", | ||
"version": "0.2.13-fixmemoryleak-beta.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Lightweight date operations library.", |
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
655
45086