From 3c3ec45dc0ce147f6f747ce45b3fca642be82ba1 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 3 Jan 2024 22:44:14 -0500 Subject: [PATCH] fix: Show count of days rather than relative time on notice, closes #6330 --- app/scenes/Document/components/Notices.tsx | 18 ++++++++++++++++-- shared/i18n/locales/en_US/translation.json | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/scenes/Document/components/Notices.tsx b/app/scenes/Document/components/Notices.tsx index c4089f32d..3eb696a99 100644 --- a/app/scenes/Document/components/Notices.tsx +++ b/app/scenes/Document/components/Notices.tsx @@ -1,3 +1,4 @@ +import differenceInDays from "date-fns/differenceInDays"; import { TrashIcon, ArchiveIcon, ShapesIcon, InputIcon } from "outline-icons"; import * as React from "react"; import { Trans, useTranslation } from "react-i18next"; @@ -11,6 +12,19 @@ type Props = { readOnly: boolean; }; +function Days(props: { dateTime: string }) { + const { t } = useTranslation(); + const days = differenceInDays(new Date(props.dateTime), new Date()); + + return ( + <> + {t(`{{ count }} days`, { + count: days, + })} + + ); +} + export default function Notices({ document, readOnly }: Props) { const { t } = useTranslation(); @@ -22,12 +36,12 @@ export default function Notices({ document, readOnly }: Props) { return document.template ? ( This template will be permanently deleted in{" "} - ) : ( This document will be permanently deleted in{" "} - ); } diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index dd966bdca..c8a234c02 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -553,6 +553,8 @@ "Viewer insights": "Viewer insights", "As an admin you can manage if team members can see who has viewed this document": "As an admin you can manage if team members can see who has viewed this document", "Sorry, the last change could not be persisted – please reload the page": "Sorry, the last change could not be persisted – please reload the page", + "{{ count }} days": "{{ count }} day", + "{{ count }} days_plural": "{{ count }} days", "This template will be permanently deleted in <2> unless restored.": "This template will be permanently deleted in <2> unless restored.", "This document will be permanently deleted in <2> unless restored.": "This document will be permanently deleted in <2> unless restored.", "Highlight some text and use the <1> control to add placeholders that can be filled out when creating new documents": "Highlight some text and use the <1> control to add placeholders that can be filled out when creating new documents",