1
0
mirror of https://github.com/SomboChea/ui synced 2024-11-24 06:54:27 +07:00

fix: time format localization (#471)

This commit is contained in:
hdmr14 2020-05-03 22:17:38 +09:00 committed by GitHub
parent 1e060474c7
commit c9910c97b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -50,7 +50,7 @@ describe('formatRepository', (): void => {
describe('formatDate', (): void => {
test('should format the date', (): void => {
const date = 1532211072138;
expect(formatDate(date)).toEqual('21.07.2018, 22:11:12');
expect(formatDate(date)).toEqual('07/21/2018 10:11:12 PM');
});
});
@ -78,7 +78,7 @@ describe('formatDateDistance', (): void => {
describe('getLastUpdatedPackageTime', (): void => {
test('should get the last update time', (): void => {
const lastUpdated = packageMeta._uplinks;
expect(getLastUpdatedPackageTime(lastUpdated)).toEqual('22.07.2018, 22:11:12');
expect(getLastUpdatedPackageTime(lastUpdated)).toEqual('07/22/2018 10:11:12 PM');
});
test('should get the last update time for blank uplink', (): void => {
@ -91,9 +91,9 @@ describe('getRecentReleases', (): void => {
test('should get the recent releases', (): void => {
const { time } = packageMeta;
const result = [
{ time: '14.12.2017, 15:43:27', version: '2.7.1' },
{ time: '05.12.2017, 23:25:06', version: '2.7.0' },
{ time: '08.11.2017, 22:47:16', version: '2.6.6' },
{ time: '12/14/2017 3:43:27 PM', version: '2.7.1' },
{ time: '12/05/2017 11:25:06 PM', version: '2.7.0' },
{ time: '11/08/2017 10:47:16 PM', version: '2.6.6' },
];
expect(getRecentReleases(time)).toEqual(result);
expect(getRecentReleases()).toEqual([]);

View File

@ -5,12 +5,14 @@ import { UpLinks } from '@verdaccio/types';
import isString from 'lodash/isString';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import { Time } from '../../types/packageMeta';
export const TIMEFORMAT = 'DD.MM.YYYY, HH:mm:ss';
export const TIMEFORMAT = 'L LTS';
dayjs.extend(relativeTime);
dayjs.extend(localizedFormat);
/**
* Formats license field for webui.