chore(localize): rename normalizeDate to normalizeIntlDate
This commit is contained in:
parent
9945f91deb
commit
4500557f78
4 changed files with 8 additions and 8 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { getLocale } from './getLocale.js';
|
import { getLocale } from './getLocale.js';
|
||||||
import { normalizeDate } from './normalizeDate.js';
|
import { normalizeIntlDate } from './normalizeIntlDate.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats date based on locale and options
|
* Formats date based on locale and options
|
||||||
|
|
@ -36,5 +36,5 @@ export function formatDate(date, options) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
formattedDate = '';
|
formattedDate = '';
|
||||||
}
|
}
|
||||||
return normalizeDate(formattedDate);
|
return normalizeIntlDate(formattedDate);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { normalizeDate } from './normalizeDate.js';
|
import { normalizeIntlDate } from './normalizeIntlDate.js';
|
||||||
|
|
||||||
const monthsLocaleCache = {};
|
const monthsLocaleCache = {};
|
||||||
|
|
||||||
|
|
@ -6,7 +6,7 @@ const monthsLocaleCache = {};
|
||||||
* @desc Returns month names for locale
|
* @desc Returns month names for locale
|
||||||
* @param {string} options.locale locale
|
* @param {string} options.locale locale
|
||||||
* @param {string} [options.style=long] long, short or narrow
|
* @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' } = {}) {
|
export function getMonthNames({ locale, style = 'long' } = {}) {
|
||||||
let months = monthsLocaleCache[locale] && monthsLocaleCache[locale][style];
|
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) {
|
for (let i = 0; i < 12; i += 1) {
|
||||||
const date = new Date(2019, i, 1);
|
const date = new Date(2019, i, 1);
|
||||||
const formattedDate = formatter.format(date);
|
const formattedDate = formatter.format(date);
|
||||||
const normalizedDate = normalizeDate(formattedDate);
|
const normalizedDate = normalizeIntlDate(formattedDate);
|
||||||
months.push(normalizedDate);
|
months.push(normalizedDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { normalizeDate } from './normalizeDate.js';
|
import { normalizeIntlDate } from './normalizeIntlDate.js';
|
||||||
|
|
||||||
const weekdayNamesCache = {};
|
const weekdayNamesCache = {};
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ function getCachedWeekdayNames(locale) {
|
||||||
const date = new Date('2019/04/07'); // start from Sunday
|
const date = new Date('2019/04/07'); // start from Sunday
|
||||||
for (let i = 0; i < 7; i += 1) {
|
for (let i = 0; i < 7; i += 1) {
|
||||||
const weekday = formatter.format(date);
|
const weekday = formatter.format(date);
|
||||||
const normalizedWeekday = normalizeDate(weekday);
|
const normalizedWeekday = normalizeIntlDate(weekday);
|
||||||
weekdays.push(normalizedWeekday);
|
weekdays.push(normalizedWeekday);
|
||||||
date.setDate(date.getDate() + 1);
|
date.setDate(date.getDate() + 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
* @param str
|
* @param str
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
export function normalizeDate(str) {
|
export function normalizeIntlDate(str) {
|
||||||
const dateString = [];
|
const dateString = [];
|
||||||
for (let i = 0, n = str.length; i < n; i += 1) {
|
for (let i = 0, n = str.length; i < n; i += 1) {
|
||||||
// remove unicode 160
|
// remove unicode 160
|
||||||
Loading…
Reference in a new issue