aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_reminders
diff options
context:
space:
mode:
authorChristopher Ng <chrng8@gmail.com>2023-08-03 16:35:43 -0700
committerChristopher Ng <chrng8@gmail.com>2023-08-09 10:41:18 -0700
commit440959a014f4645d1d0154662d184eaea4bf014e (patch)
tree4ddc8b2140ce495503aefdd8010d47cd86242555 /apps/files_reminders
parentc2dfc42899eaa8110e533ba9e09ea7b0fe5308aa (diff)
downloadnextcloud-server-440959a014f4645d1d0154662d184eaea4bf014e.tar.gz
nextcloud-server-440959a014f4645d1d0154662d184eaea4bf014e.zip
enh: shorten date string if same day
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/files_reminders')
-rw-r--r--apps/files_reminders/src/shared/utils.ts19
1 files changed, 13 insertions, 6 deletions
diff --git a/apps/files_reminders/src/shared/utils.ts b/apps/files_reminders/src/shared/utils.ts
index 41b252a3910..358ca09aa25 100644
--- a/apps/files_reminders/src/shared/utils.ts
+++ b/apps/files_reminders/src/shared/utils.ts
@@ -89,17 +89,24 @@ export const getDateTime = (dateTime: DateTimePreset): Date => {
}
export const getDateString = (dueDate: Date): string => {
- let localeOptions: Intl.DateTimeFormatOptions = {
- weekday: 'short',
+ let formatOptions: Intl.DateTimeFormatOptions = {
hour: 'numeric',
minute: '2-digit',
}
- const today = moment()
const dueDateMoment = moment(dueDate)
+ const today = moment()
+
+ if (!dueDateMoment.isSame(today, 'date')) {
+ formatOptions = {
+ ...formatOptions,
+ weekday: 'short',
+ }
+ }
+
if (!dueDateMoment.isSame(today, 'week')) {
- localeOptions = {
- ...localeOptions,
+ formatOptions = {
+ ...formatOptions,
month: 'short',
day: 'numeric',
}
@@ -107,7 +114,7 @@ export const getDateString = (dueDate: Date): string => {
return dueDate.toLocaleString(
getCanonicalLocale(),
- localeOptions,
+ formatOptions,
)
}