Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import moment from 'moment';
import 'moment/locale/ja';
import { DateTime } from 'luxon';
import fecha from 'fecha';
import { format as dateFnsFormat } from 'date-fns';
import dateFnsLocaleJa from 'date-fns/locale/ja';
import dateformat from 'dateformat';
import litdate from 'lit-date';
const date = new Date('2000-01-06T12:34:56.789Z');
const expected = '1月6日(木)';
// Prepare
const dayOfWeekToName = ({ dayOfWeek }) => ['日', '月', '火', '水', '木', '金', '土'][dayOfWeek];
Object.assign(dateformat.i18n, {
dayNames: ['日', '月', '火', '水', '木', '金', '土'],
});
Object.assign(fecha.i18n, {
dayNamesShort: ['日', '月', '火', '水', '木', '金', '土'],
});
suite('Advanced usage', () => {
benchmark('moment', () => {
const actual = moment(date)
.locale('ja')
.format('M月D日(ddd)');
console.assert(actual === expected);
});
benchmark('luxon', () => {
const actual = DateTime.fromJSDate(date)
.setLocale('ja')