rewrite using isToday helper

This commit is contained in:
Artem Baskal 2020-01-17 17:40:47 +03:00
parent a3020275a2
commit af7b9523b5
2 changed files with 6 additions and 17 deletions
client/src/helpers

View file

@ -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';
@ -48,21 +49,10 @@ export const formatDateTime = (dateTime) => {
};
/**
* @param string The date to format
* @returns string Returns the date in the format DD/MM/YYYY
* @param string
* @returns boolean
*/
export const formatTodayDate = (dateTime) => {
const currentLanguage = i18n.languages[0] || 'en';
const parsedTime = dateParse(dateTime);
const options = {
year: 'numeric',
month: 'numeric',
day: 'numeric',
hour12: false,
};
return parsedTime.toLocaleString(currentLanguage, options);
};
export const isToday = date => isSameDay(new Date(date), new Date());
export const normalizeLogs = logs => logs.map((log) => {
const {