@finema/finework-layer 0.2.131 → 0.2.133
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/CHANGELOG.md +8 -0
- package/app/components/Format/TimeFromNow.vue +56 -16
- package/bun.lock +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.133](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/0.2.132...0.2.133) (2026-02-10)
|
|
4
|
+
|
|
5
|
+
## [0.2.132](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/0.2.131...0.2.132) (2026-02-10)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* timeformnow ([82712ff](https://gitlab.finema.co/finema/finework/finework-frontend-layer/commit/82712fffacd6f3329934dfc50115d353eaacb63b))
|
|
10
|
+
|
|
3
11
|
## [0.2.131](https://gitlab.finema.co/finema/finework/finework-frontend-layer/compare/0.2.130...0.2.131) (2026-02-06)
|
|
4
12
|
|
|
5
13
|
### Bug Fixes
|
|
@@ -8,32 +8,72 @@
|
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script lang="ts" setup>
|
|
11
|
-
import {
|
|
12
|
-
import * as locales from 'date-fns/locale'
|
|
11
|
+
import { differenceInDays, differenceInHours, differenceInMinutes, differenceInMonths, differenceInWeeks, startOfDay, addDays } from 'date-fns'
|
|
13
12
|
|
|
14
13
|
const props = defineProps<{
|
|
15
14
|
value: string | Date
|
|
16
15
|
as?: string
|
|
17
16
|
}>()
|
|
18
17
|
|
|
19
|
-
const config = useAppConfig()
|
|
20
|
-
const localeInject = inject('locale')
|
|
21
|
-
|
|
22
18
|
const getValue = computed(() => {
|
|
23
|
-
const locale = (localeInject ?? config.core.locale) === 'th'
|
|
24
|
-
? locales.th
|
|
25
|
-
: locales.enUS
|
|
26
|
-
|
|
27
19
|
const targetDate = new Date(props.value)
|
|
28
|
-
const
|
|
20
|
+
const now = new Date()
|
|
21
|
+
|
|
22
|
+
// Compare only the date part
|
|
23
|
+
const nowDate = startOfDay(now)
|
|
24
|
+
const dueDateOnly = startOfDay(targetDate)
|
|
25
|
+
|
|
26
|
+
if (nowDate > dueDateOnly) {
|
|
27
|
+
const dueDateEnd = addDays(dueDateOnly, 1)
|
|
28
|
+
|
|
29
|
+
const months = differenceInMonths(now, dueDateEnd)
|
|
30
|
+
|
|
31
|
+
if (months > 0) {
|
|
32
|
+
return months === 1 ? '1 month ago' : `${months} months ago`
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const weeks = differenceInWeeks(now, dueDateEnd)
|
|
36
|
+
|
|
37
|
+
if (weeks > 0) {
|
|
38
|
+
return weeks === 1 ? '1 week ago' : `${weeks} weeks ago`
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const days = differenceInDays(now, dueDateEnd)
|
|
42
|
+
|
|
43
|
+
if (days > 0) {
|
|
44
|
+
return days === 1 ? '1 day ago' : `${days} days ago`
|
|
45
|
+
}
|
|
29
46
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
47
|
+
const hours = differenceInHours(now, dueDateEnd)
|
|
48
|
+
|
|
49
|
+
if (hours > 0) {
|
|
50
|
+
return hours === 1 ? '1hr ago' : `${hours}hr ago`
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const minutes = differenceInMinutes(now, dueDateEnd)
|
|
54
|
+
|
|
55
|
+
if (minutes > 0) {
|
|
56
|
+
return minutes === 1 ? '1m ago' : `${minutes}m ago`
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return 'just now'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Today
|
|
63
|
+
if (nowDate.getTime() === dueDateOnly.getTime()) {
|
|
64
|
+
return 'Today'
|
|
35
65
|
}
|
|
36
66
|
|
|
37
|
-
|
|
67
|
+
// Tomorrow
|
|
68
|
+
const tomorrow = addDays(nowDate, 1)
|
|
69
|
+
|
|
70
|
+
if (tomorrow.getTime() === dueDateOnly.getTime()) {
|
|
71
|
+
return 'Tomorrow'
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// In X days (future)
|
|
75
|
+
const days = differenceInDays(dueDateOnly, nowDate)
|
|
76
|
+
|
|
77
|
+
return `in ${days}d`
|
|
38
78
|
})
|
|
39
79
|
</script>
|
package/bun.lock
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"": {
|
|
5
5
|
"name": "@finema/finework-layer",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@finema/core": "^3.
|
|
7
|
+
"@finema/core": "^3.11.0",
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@finema/eslint-config": "^2.0.3",
|
|
@@ -183,7 +183,7 @@
|
|
|
183
183
|
|
|
184
184
|
"@eslint/plugin-kit": ["@eslint/plugin-kit@0.4.1", "", { "dependencies": { "@eslint/core": "^0.17.0", "levn": "^0.4.1" } }, "sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA=="],
|
|
185
185
|
|
|
186
|
-
"@finema/core": ["@finema/core@3.
|
|
186
|
+
"@finema/core": ["@finema/core@3.11.0", "", { "dependencies": { "@iconify-json/heroicons": "^1.2.2", "@iconify-json/ph": "^1.2.2", "@iconify-json/svg-spinners": "^1.2.2", "@nuxt/kit": "^4.1.3", "@nuxt/ui": "^4.4.0", "@pinia/nuxt": "^0.11.0", "@tailwindcss/typography": "^0.5.0-alpha.3", "@tiptap/extension-text-align": "^3.18.0", "@vee-validate/nuxt": "^4.15.1", "@vee-validate/valibot": "^4.15.1", "@vuepic/vue-datepicker": "^11.0.2", "@vueuse/components": "^13.9.0", "@vueuse/core": "^13.9.0", "@wdns/vue-code-block": "^2.3.5", "axios": "^1.10.0", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "defu": "^6.1.4", "lodash-es": "^4.17.21", "maska": "^3.1.1", "url-join": "^5.0.0" } }, "sha512-hZEpL4LcNnh6kWSISqhirP8BepUcm9uj8UCuEVC3W6DeR38yVxf5UD4i0NyhFQXvYa0d070tql4GjnedRnFsXw=="],
|
|
187
187
|
|
|
188
188
|
"@finema/eslint-config": ["@finema/eslint-config@2.0.4", "", { "dependencies": { "eslint-plugin-better-tailwindcss": "^3.7.10", "eslint-plugin-tailwindcss": "^3.18.2", "eslint-plugin-unused-imports": "^4.2.0" }, "peerDependencies": { "eslint": "^9.37.0" } }, "sha512-kKznMgbsOfPPg+td53dK36I3YFo6Ji4GAwKbVS2pimuQfcJT4mbgnEXCuW1Q/uNvUaFItr1NCSSD1LtEQTNNug=="],
|
|
189
189
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finema/finework-layer",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.133",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "nuxi dev .playground -o",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"vue": "latest"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@finema/core": "^3.
|
|
33
|
+
"@finema/core": "^3.11.0"
|
|
34
34
|
},
|
|
35
35
|
"lint-staged": {
|
|
36
36
|
"*": "eslint"
|