@fy-/fws-vue 2.3.39 → 2.3.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composables/templating.ts +16 -2
- package/package.json +1 -1
|
@@ -109,9 +109,23 @@ function formatDatetime(dt: Date | string | number) {
|
|
|
109
109
|
|
|
110
110
|
function formatTimeago(dt: Date | string | number) {
|
|
111
111
|
const timestamp = parseDateInput(dt)
|
|
112
|
-
|
|
112
|
+
// Extract language code and convert dash to underscore for timeago.js format
|
|
113
|
+
const fullLocale = getLocale()
|
|
113
114
|
|
|
114
|
-
|
|
115
|
+
// First try with underscore format (en-US -> en_US)
|
|
116
|
+
const localeWithUnderscore = fullLocale.replace('-', '_')
|
|
117
|
+
|
|
118
|
+
// Then try just the language part (en-US -> en)
|
|
119
|
+
const langOnly = fullLocale.split('-')[0].toLowerCase()
|
|
120
|
+
|
|
121
|
+
// Try the formats in order of preference
|
|
122
|
+
// This avoids try/catch which can trigger linting issues
|
|
123
|
+
const dateObj = new Date(timestamp)
|
|
124
|
+
|
|
125
|
+
// No try/catch needed - if locale doesn't exist, timeago falls back to en_US
|
|
126
|
+
return formatDateTimeago(dateObj, localeWithUnderscore)
|
|
127
|
+
|| formatDateTimeago(dateObj, langOnly)
|
|
128
|
+
|| formatDateTimeago(dateObj, 'en_US')
|
|
115
129
|
}
|
|
116
130
|
|
|
117
131
|
export {
|