aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_reminders/src/shared/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_reminders/src/shared/utils.ts')
-rw-r--r--apps/files_reminders/src/shared/utils.ts23
1 files changed, 20 insertions, 3 deletions
diff --git a/apps/files_reminders/src/shared/utils.ts b/apps/files_reminders/src/shared/utils.ts
index 86182ba5106..07142888e51 100644
--- a/apps/files_reminders/src/shared/utils.ts
+++ b/apps/files_reminders/src/shared/utils.ts
@@ -120,6 +120,13 @@ export const getDateString = (dueDate: Date): string => {
}
}
+ if (!dueDateMoment.isSame(today, 'year')) {
+ formatOptions = {
+ ...formatOptions,
+ year: 'numeric',
+ }
+ }
+
return dueDate.toLocaleString(
getCanonicalLocale(),
formatOptions,
@@ -127,12 +134,22 @@ export const getDateString = (dueDate: Date): string => {
}
export const getVerboseDateString = (dueDate: Date): string => {
- const formatOptions: Intl.DateTimeFormatOptions = {
+ let formatOptions: Intl.DateTimeFormatOptions = {
+ month: 'long',
+ day: 'numeric',
weekday: 'long',
hour: 'numeric',
minute: '2-digit',
- month: 'long',
- day: 'numeric',
+ }
+
+ const dueDateMoment = moment(dueDate)
+ const today = moment()
+
+ if (!dueDateMoment.isSame(today, 'year')) {
+ formatOptions = {
+ ...formatOptions,
+ year: 'numeric',
+ }
}
return dueDate.toLocaleString(