feat: add absolute timestamps, close #498 (#573)

This commit is contained in:
Xylight authored and GitHub committed 2025-06-15 10:47:16 -07:00
1 parent d90ece1a76
commit 346d89f7cc
4 files changed
+25 -4

No files matched your search

+12 -3
View File
@@ -26,9 +26,17 @@
let language = locale ?? 'en'
const rtf = new Intl.RelativeTimeFormat(language, options)
return rtf.format(-value, thresholds[i].unit as 'second')
if (settings.absoluteDates) {
const rtf = new Intl.DateTimeFormat(language, {
...options,
timeStyle: 'short',
dateStyle: 'short',
})
return rtf.format(date)
} else {
const rtf = new Intl.RelativeTimeFormat(language, options)
return rtf.format(-value, thresholds[i].unit as 'second')
}
}
}
return 'Now'
@@ -40,6 +48,7 @@
<script lang="ts">
import { locale } from '$lib/i18n/translations'
import { settings } from '$lib/settings.svelte'
const toLocaleDateString = (date: Date): string => {
try {
+4
View File
@@ -814,6 +814,10 @@
"reverseActions": {
"title": "Reverse action row",
"description": "Reverses the order of actions on posts and comments."
},
"absoluteDates": {
"title": "Absolute timestamps",
"description": "Replaces relative timestamps (3 hours ago) with absolute ones (15/6/25)"
}
},
"embeds": {
+4 -1
View File
@@ -97,10 +97,12 @@ interface Settings {
useRtl: boolean
parseTags: boolean
logoColorMonth: number | null
absoluteDates: boolean
}
export const defaultSettings: Settings = {
settingsVer: 3,
settingsVer: 4,
expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true,
markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true,
showInstances: {
@@ -171,6 +173,7 @@ export const defaultSettings: Settings = {
useRtl: false,
parseTags: true,
logoColorMonth: null,
absoluteDates: false,
}
function createSettingsState(initial: Settings): Settings {
+5
View File
@@ -381,6 +381,11 @@
title={$t('settings.app.limitLayoutWidth.title')}
description={$t('settings.app.limitLayoutWidth.description')}
/>
<ToggleSetting
bind:checked={settings.absoluteDates}
title={$t('settings.app.absoluteDates.title')}
description={$t('settings.app.absoluteDates.description')}
/>
<ToggleSetting
supportedPlatforms={{ desktop: false, tablet: false, mobile: true }}
bind:checked={settings.dock.autoHide}