From 4500557f7877e3b0a752d6c662dc5faaa042c104 Mon Sep 17 00:00:00 2001 From: qa46hx Date: Fri, 4 Oct 2019 14:27:10 +0200 Subject: [PATCH] chore(localize): rename normalizeDate to normalizeIntlDate --- packages/localize/src/date/formatDate.js | 4 ++-- packages/localize/src/date/getMonthNames.js | 6 +++--- packages/localize/src/date/getWeekdayNames.js | 4 ++-- .../src/date/{normalizeDate.js => normalizeIntlDate.js} | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) rename packages/localize/src/date/{normalizeDate.js => normalizeIntlDate.js} (91%) diff --git a/packages/localize/src/date/formatDate.js b/packages/localize/src/date/formatDate.js index 3353a7989..d72599c84 100644 --- a/packages/localize/src/date/formatDate.js +++ b/packages/localize/src/date/formatDate.js @@ -1,5 +1,5 @@ import { getLocale } from './getLocale.js'; -import { normalizeDate } from './normalizeDate.js'; +import { normalizeIntlDate } from './normalizeIntlDate.js'; /** * Formats date based on locale and options @@ -36,5 +36,5 @@ export function formatDate(date, options) { } catch (e) { formattedDate = ''; } - return normalizeDate(formattedDate); + return normalizeIntlDate(formattedDate); } diff --git a/packages/localize/src/date/getMonthNames.js b/packages/localize/src/date/getMonthNames.js index cb6388a0d..66841bb24 100644 --- a/packages/localize/src/date/getMonthNames.js +++ b/packages/localize/src/date/getMonthNames.js @@ -1,4 +1,4 @@ -import { normalizeDate } from './normalizeDate.js'; +import { normalizeIntlDate } from './normalizeIntlDate.js'; const monthsLocaleCache = {}; @@ -6,7 +6,7 @@ const monthsLocaleCache = {}; * @desc Returns month names for locale * @param {string} options.locale locale * @param {string} [options.style=long] long, short or narrow - * @returns {Array} like: ['Januray', 'February', ...etc]. + * @returns {Array} like: ['January', 'February', ...etc]. */ export function getMonthNames({ locale, style = 'long' } = {}) { let months = monthsLocaleCache[locale] && monthsLocaleCache[locale][style]; @@ -21,7 +21,7 @@ export function getMonthNames({ locale, style = 'long' } = {}) { for (let i = 0; i < 12; i += 1) { const date = new Date(2019, i, 1); const formattedDate = formatter.format(date); - const normalizedDate = normalizeDate(formattedDate); + const normalizedDate = normalizeIntlDate(formattedDate); months.push(normalizedDate); } diff --git a/packages/localize/src/date/getWeekdayNames.js b/packages/localize/src/date/getWeekdayNames.js index aec20bb12..03f9d2727 100644 --- a/packages/localize/src/date/getWeekdayNames.js +++ b/packages/localize/src/date/getWeekdayNames.js @@ -1,4 +1,4 @@ -import { normalizeDate } from './normalizeDate.js'; +import { normalizeIntlDate } from './normalizeIntlDate.js'; const weekdayNamesCache = {}; @@ -23,7 +23,7 @@ function getCachedWeekdayNames(locale) { const date = new Date('2019/04/07'); // start from Sunday for (let i = 0; i < 7; i += 1) { const weekday = formatter.format(date); - const normalizedWeekday = normalizeDate(weekday); + const normalizedWeekday = normalizeIntlDate(weekday); weekdays.push(normalizedWeekday); date.setDate(date.getDate() + 1); } diff --git a/packages/localize/src/date/normalizeDate.js b/packages/localize/src/date/normalizeIntlDate.js similarity index 91% rename from packages/localize/src/date/normalizeDate.js rename to packages/localize/src/date/normalizeIntlDate.js index 83f6dc0a6..c606f44f9 100644 --- a/packages/localize/src/date/normalizeDate.js +++ b/packages/localize/src/date/normalizeIntlDate.js @@ -4,7 +4,7 @@ * @param str * @returns {string} */ -export function normalizeDate(str) { +export function normalizeIntlDate(str) { const dateString = []; for (let i = 0, n = str.length; i < n; i += 1) { // remove unicode 160