Skip to content

Commit 035931c

Browse files
committed
fix: imprecise age count
1 parent 3b9c870 commit 035931c

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"h3": "^1.7.1",
4646
"highlight.js": "^11.8.0",
4747
"js-base64": "^3.7.5",
48+
"longevity-js": "^0.0.2",
4849
"markdown-it": "^13.0.1",
4950
"markdown-it-anchor": "^8.6.7",
5051
"markdown-it-emoji": "^2.0.2",

pages/index.vue

+2-4
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676

7777
<script lang="ts" setup>
7878
import VueWriter from 'vue-writer'
79+
import { calcAge } from 'longevity-js'
7980
import { SOCIAL_LINKS } from '@/config/links'
8081
8182
if (process.client) {
@@ -113,8 +114,5 @@ onMounted(() => {
113114
emailAddr.value = localStorage.getItem('email')
114115
})
115116
116-
const age = (
117-
(new Date().getTime() - Date.parse(atob('MjAwOC0xMC0xOQ=='))) /
118-
(24 * 60 * 60 * 1000 * 365)
119-
).toFixed(2)
117+
const age = calcAge(new Date('2008-10-19T21:30:00.000+08:00')).toFixed(2)
120118
</script>

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -5593,6 +5593,11 @@ longest@^2.0.1:
55935593
resolved "https://registry.yarnpkg.com/longest/-/longest-2.0.1.tgz#781e183296aa94f6d4d916dc335d0d17aefa23f8"
55945594
integrity sha512-Ajzxb8CM6WAnFjgiloPsI3bF+WCxcvhdIG3KNA2KN962+tdBsHcuQ4k4qX/EcS/2CRkcc0iAkR956Nib6aXU/Q==
55955595

5596+
longevity-js@^0.0.2:
5597+
version "0.0.2"
5598+
resolved "https://registry.yarnpkg.com/longevity-js/-/longevity-js-0.0.2.tgz#faa6facce92ba04f17192defd49341ad203e63c1"
5599+
integrity sha512-eh2DVJbOOp3ZvGAsdePC4JTZyrAKuWo1DIpBnfvY7rtMxU0yxYd2rZouU6y5lUHkQHIG9cMNphsjkAeeUsFixg==
5600+
55965601
lru-cache@^10.0.1, lru-cache@^10.2.0, "lru-cache@^9.1.1 || ^10.0.0":
55975602
version "10.2.0"
55985603
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.0.tgz#0bd445ca57363465900f4d1f9bd8db343a4d95c3"

0 commit comments

Comments
 (0)