Skip to content

Commit 396937e

Browse files
committed
Show creation date in plan page
1 parent fea68fd commit 396937e

File tree

6 files changed

+44
-3
lines changed

6 files changed

+44
-3
lines changed

app/static/dist/.vite/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
]
3939
},
4040
"app/static/js/plan.js": {
41-
"file": "assets/plan-Bwjl4Amt.js",
41+
"file": "assets/plan-Cu_Fu6tG.js",
4242
"name": "plan",
4343
"src": "app/static/js/plan.js",
4444
"isEntry": true,

app/static/dist/assets/plan-Bwjl4Amt.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/static/dist/assets/plan-Cu_Fu6tG.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/static/js/created.vue

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<small class="lh-1"
3+
><small
4+
>created <span :title="longDate">on {{ shortDate }}</span></small
5+
></small
6+
>
7+
</template>
8+
9+
<script setup>
10+
import { computed, ref } from "vue";
11+
const props = defineProps(["date"]);
12+
const dateObj = new Date(props.date);
13+
14+
const language = ref(navigator.language);
15+
16+
const shortDate = computed(() => {
17+
// Format according to the user's locale
18+
return dateObj.toLocaleString(navigator.language, {
19+
year: "numeric", // Example: "2023"
20+
month: "short", // Example: "Nov"
21+
day: "numeric", // Example: "9"
22+
});
23+
});
24+
25+
const longDate = computed(() => {
26+
// Format according to the user's locale
27+
return dateObj.toLocaleString(navigator.language, {
28+
weekday: "short", // Example: "Thu"
29+
year: "numeric", // Example: "2023"
30+
month: "short", // Example: "Nov"
31+
day: "numeric", // Example: "9"
32+
hour: "numeric", // Example: "11"
33+
minute: "numeric", // Example: "15"
34+
second: "numeric", // Optional: show seconds
35+
timeZoneName: "short", // Show time zone like "GMT+1"
36+
});
37+
});
38+
</script>

app/static/js/plan.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import "./common.js";
22
import { createApp } from "vue";
33
import { Plan } from "pev2";
44
import { ref } from "vue";
5+
import Created from "./created.vue";
56

67
import "pev2/dist/style.css";
78

@@ -18,6 +19,7 @@ const app = createApp({
1819
},
1920
components: {
2021
pev2: Plan,
22+
created: Created,
2123
},
2224
});
2325
app.component("font-awesome-icon", FontAwesomeIcon);

app/templates/plan.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@
3232
{% raw %}{{ plan.title || '' }}{% endraw %}
3333
</span>
3434
{% if plan %}
35-
<span class="navbar-text">
35+
<span class="navbar-text p-0 text-end d-flex flex-column">
3636
<a href="{{ url_for('plan_from_db', id=plan.id) }}">
3737
<font-awesome-icon icon="link"></font-awesome-icon>
3838
plan/{{ plan.id }}
3939
</a>
40+
<created date="{{ plan.created }}"></created>
4041
</span>
4142
{% endif %}
4243
</nav>

0 commit comments

Comments
 (0)