chore(localize): rename normalizeDate to normalizeIntlDate

This commit is contained in:
qa46hx 2019-10-04 14:27:10 +02:00
parent 9945f91deb
commit 4500557f78
4 changed files with 8 additions and 8 deletions

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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