mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2025-05-01 05:31:38 +03:00
Merge: + client: show date in query logs
Close #1202
* commit 'af7b9523b5
':
rewrite using isToday helper
+ client: add jsdocs with returning format of date format functions
+ client: show date in query logs
This commit is contained in:
commit
3166607540
2 changed files with 20 additions and 4 deletions
client/src/helpers
|
@ -5,6 +5,7 @@ import subHours from 'date-fns/sub_hours';
|
|||
import addHours from 'date-fns/add_hours';
|
||||
import addDays from 'date-fns/add_days';
|
||||
import subDays from 'date-fns/sub_days';
|
||||
import isSameDay from 'date-fns/is_same_day';
|
||||
import round from 'lodash/round';
|
||||
import axios from 'axios';
|
||||
import i18n from 'i18next';
|
||||
|
@ -19,11 +20,19 @@ import {
|
|||
DNS_RECORD_TYPES,
|
||||
} from './constants';
|
||||
|
||||
/**
|
||||
* @param string The time to format
|
||||
* @returns string Returns the time in the format HH:mm:ss
|
||||
*/
|
||||
export const formatTime = (time) => {
|
||||
const parsedTime = dateParse(time);
|
||||
return dateFormat(parsedTime, 'HH:mm:ss');
|
||||
};
|
||||
|
||||
/**
|
||||
* @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';
|
||||
const parsedTime = dateParse(dateTime);
|
||||
|
@ -39,6 +48,12 @@ export const formatDateTime = (dateTime) => {
|
|||
return parsedTime.toLocaleString(currentLanguage, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @returns boolean
|
||||
*/
|
||||
export const isToday = date => isSameDay(new Date(date), new Date());
|
||||
|
||||
export const normalizeLogs = logs => logs.map((log) => {
|
||||
const {
|
||||
time,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue