mirror of
https://github.com/nextcloud/server.git
synced 2026-06-14 19:20:35 -04:00
fix(files_reminders): Add year to date string if not in the same year
Signed-off-by: Christopher Ng <chrng8@gmail.com>
This commit is contained in:
parent
c9139c64ff
commit
8f7829ea90
1 changed files with 30 additions and 13 deletions
|
|
@ -120,19 +120,36 @@ export const getDateString = (dueDate: Date): string => {
|
|||
}
|
||||
}
|
||||
|
||||
return dueDate.toLocaleString(
|
||||
getCanonicalLocale(),
|
||||
formatOptions,
|
||||
)
|
||||
}
|
||||
|
||||
export const getVerboseDateString = (dueDate: Date): string => {
|
||||
const formatOptions: Intl.DateTimeFormatOptions = {
|
||||
weekday: 'long',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
if (!dueDateMoment.isSame(today, 'year')) {
|
||||
formatOptions = {
|
||||
...formatOptions,
|
||||
year: 'numeric',
|
||||
}
|
||||
}
|
||||
|
||||
return dueDate.toLocaleString(
|
||||
getCanonicalLocale(),
|
||||
formatOptions,
|
||||
)
|
||||
}
|
||||
|
||||
export const getVerboseDateString = (dueDate: Date): string => {
|
||||
let formatOptions: Intl.DateTimeFormatOptions = {
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
weekday: 'long',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
}
|
||||
|
||||
const dueDateMoment = moment(dueDate)
|
||||
const today = moment()
|
||||
|
||||
if (!dueDateMoment.isSame(today, 'year')) {
|
||||
formatOptions = {
|
||||
...formatOptions,
|
||||
year: 'numeric',
|
||||
}
|
||||
}
|
||||
|
||||
return dueDate.toLocaleString(
|
||||
|
|
|
|||
Loading…
Reference in a new issue