mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-04-30 13:11:37 +03:00
Merge: + client: add detailed date format for filters
Close #624 Squashed commit of the following: commit 5a66d8ca350880abd0a7a146b75df385aa8f97b4 Author: Artem Baskal <a.baskal@adguard.com> Date: Mon Jan 20 19:16:27 2020 +0300 update CellWrap logic commit 072586493ef2cb73ba514a01d8b7f8904d4f5754 Author: Artem Baskal <a.baskal@adguard.com> Date: Mon Jan 20 15:37:26 2020 +0300 fix invalid date case commit bd2a21f2c788b2835485f4697dac1b797d5559c0 Author: Artem Baskal <a.baskal@adguard.com> Date: Fri Jan 17 18:44:23 2020 +0300 + client: add detailed date format for filters
This commit is contained in:
parent
ce7f1e231b
commit
ac156b9612
8 changed files with 62 additions and 64 deletions
client/src/helpers
|
@ -18,6 +18,10 @@ import {
|
|||
STANDARD_HTTPS_PORT,
|
||||
CHECK_TIMEOUT,
|
||||
DNS_RECORD_TYPES,
|
||||
DEFAULT_TIME_FORMAT,
|
||||
DEFAULT_DATE_FORMAT_OPTIONS,
|
||||
DETAILED_DATE_FORMAT_OPTIONS,
|
||||
DEFAULT_LANGUAGE,
|
||||
} from './constants';
|
||||
|
||||
/**
|
||||
|
@ -26,28 +30,23 @@ import {
|
|||
*/
|
||||
export const formatTime = (time) => {
|
||||
const parsedTime = dateParse(time);
|
||||
return dateFormat(parsedTime, 'HH:mm:ss');
|
||||
return dateFormat(parsedTime, DEFAULT_TIME_FORMAT);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param string The date to format
|
||||
* @returns string Returns the date and time in the format DD/MM/YYYY, HH:mm
|
||||
*/
|
||||
export const formatDateTime = (dateTime) => {
|
||||
const currentLanguage = i18n.languages[0] || 'en';
|
||||
export const formatDateTime = (dateTime, options = DEFAULT_DATE_FORMAT_OPTIONS) => {
|
||||
const currentLanguage = i18n.languages[0] || DEFAULT_LANGUAGE;
|
||||
const parsedTime = dateParse(dateTime);
|
||||
const options = {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
hour12: false,
|
||||
};
|
||||
|
||||
return parsedTime.toLocaleString(currentLanguage, options);
|
||||
};
|
||||
|
||||
export const formatDetailedDateTime = dateTime =>
|
||||
formatDateTime(dateTime, DETAILED_DATE_FORMAT_OPTIONS);
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @returns boolean
|
||||
|
@ -140,7 +139,7 @@ export const normalizeFilteringStatus = (filteringStatus) => {
|
|||
id,
|
||||
url,
|
||||
enabled,
|
||||
lastUpdated: last_updated ? formatDateTime(last_updated) : '–',
|
||||
lastUpdated: last_updated,
|
||||
name,
|
||||
rulesCount: rules_count,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue