import { format , formatDistanceToNow as dateFnsFormatDistanceToNow , isToday , isYesterday , isThisWeek } from 'date-fns' ; import { dateLocale } from '@proton/shared/lib/i18n' ; import { c } from 'ttag' ; export const formatSimpleDate = ( date ) => { if ( isToday ( date ) ) { return format ( date , 'p' , { locale : dateLocale } ) ; } if ( isYesterday ( date ) ) { return c ( 'Time' ) . t `Yesterday` ; } if ( isThisWeek ( date ) ) { return format ( date , 'EEEE' , { locale : dateLocale } ) ; } return format ( date , 'PPP' , { locale : dateLocale } ) ; } ; export const formatFullDate = ( date ) => format ( date , 'PPPPp' , { locale : dateLocale } ) ; export const formatDistanceToNow = ( date ) => dateFnsFormatDistanceToNow ( date , { locale : dateLocale , addSuffix : true } ) ; export const formatFileNameDate = ( date ) => format ( date , "yyyy-MM-dd'T'HH_mm_ssxxx" , { locale : dateLocale } ) ; export const formatScheduledTimeString = ( date ) => { return format ( date , 'p' , { locale : dateLocale } ) ; } ; export const formatDateToHuman = ( date ) => { return { dateString : format ( date , 'PPPP' , { locale : dateLocale } ) , formattedTime : formatScheduledTimeString ( date ) , } ; } ;