mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-28 20:00:10 +02:00

[web] FL next invoice date formatting GitOrigin-RevId: 5f4f86d4f11c7ee217ff806d26fc3f8a79e5affc
33 lines
772 B
TypeScript
33 lines
772 B
TypeScript
import moment from 'moment'
|
|
|
|
moment.updateLocale('en', {
|
|
calendar: {
|
|
lastDay: '[Yesterday]',
|
|
sameDay: '[Today]',
|
|
nextDay: '[Tomorrow]',
|
|
lastWeek: 'ddd, Do MMM YY',
|
|
nextWeek: 'ddd, Do MMM YY',
|
|
sameElse: 'ddd, Do MMM YY',
|
|
},
|
|
})
|
|
|
|
export function formatTime(
|
|
date: moment.MomentInput,
|
|
format = 'h:mm a',
|
|
utc = false
|
|
) {
|
|
const momentDate = utc ? moment.utc(date) : moment(date)
|
|
return momentDate.format(format)
|
|
}
|
|
|
|
export function relativeDate(date: moment.MomentInput) {
|
|
return moment(date).calendar()
|
|
}
|
|
|
|
export function formatTimeBasedOnYear(date: moment.MomentInput) {
|
|
const currentDate = moment()
|
|
|
|
return currentDate.diff(date, 'years') > 0
|
|
? formatTime(date, 'D MMMM YYYY, h:mm a')
|
|
: formatTime(date, 'D MMMM, h:mm a')
|
|
}
|