Skip to content

Commit b04c874

Browse files
committed
fix(*): use readableDate instead of yearsAgo
1 parent 75a3239 commit b04c874

File tree

5 files changed

+14
-22
lines changed

5 files changed

+14
-22
lines changed

_includes/milestone-summary.njk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
<div class="milestone-summary">
44
{% if milestone.completed != 0 %}
5-
<p class="date">Completed {{ milestone.completed | yearsAgo }}</p>
5+
<p class="date">Completed {{ milestone.completed | readableDate }}</p>
66
{% elif milestone.due != 0 %}
7-
<p class="date">Due {{ milestone.due | yearsAgo }}</p>
7+
<p class="date">Due {{ milestone.due | readableDate }}</p>
88
{% else %}
99
<p class="date">No date set</p>
1010
{% endif %}
@@ -28,4 +28,4 @@
2828
{{ milestone.description | tracToHTML | safe }}
2929
</div>
3030
{% endif %}
31-
</div>
31+
</div>

content/attachment.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<hr>
4242

4343
<div class="attachment-info">
44-
<h6>File {{ attachment.filename }}, {{ attachment.size | bytesToKilos }} (added by {{ attachment.author }}, {{ attachment.time | yearsAgo }})</h6>
44+
<h6>File {{ attachment.filename }}, {{ attachment.size | bytesToKilos }} (added by {{ attachment.author }}, {{ attachment.time | readableDate }})</h6>
4545
{% if attachment.description %}
4646
<p>{{ attachment.description }}</p>
4747
{% endif %}

content/ticket.njk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@
6464
</h2>
6565

6666
<div class="ticket-dates">
67-
<p>Opened {{ ticket.time | yearsAgo }}</p>
67+
<p>Opened {{ ticket.time | readableDate }}</p>
6868
{% if ticket.status == 'closed' and ticket.closedtime %}
69-
<p>Closed {{ ticket.closedtime | yearsAgo }}</p>
69+
<p>Closed {{ ticket.closedtime | readableDate }}</p>
7070
{% endif %}
7171
{% if not ticket.closedtime or ticket.closedtime != ticket.changetime %}
72-
<p>Last modified {{ ticket.changetime | yearsAgo }}</p>
72+
<p>Last modified {{ ticket.changetime | readableDate }}</p>
7373
{% endif %}
7474
</div>
7575
</div>
@@ -149,7 +149,7 @@
149149
{% for attachment in ticketAttachments %}
150150
<li>
151151
<a href="/attachment/ticket/{{ attachment.id }}/{{ attachment.filename }}/index.html">{{ attachment.filename }}</a> ({{ attachment.size | bytesToKilos }}) - added by {{ attachment.author }}
152-
<strong>{{ attachment.time | yearsAgo }}</strong>.<br />
152+
<strong>{{ attachment.time | readableDate }}</strong>.<br />
153153
{{ attachment.description | tracToHTML | safe }}
154154
</li>
155155
{% endfor %}
@@ -161,7 +161,7 @@
161161
{% for change in ticket.changes %}
162162
<div class="ticket-change flex-column" id="comment:{{ loop.index }}">
163163
<h3 class="flex-row flex-between-start ticket-change-header">
164-
<span>Changed {{ change.time | yearsAgo }} by <span class="author">{{ change.author }}</span></span>
164+
<span>Changed {{ change.time | readableDate }} by <span class="author">{{ change.author }}</span></span>
165165
<a class="ticket-change-link" href="#comment:{{ loop.index }}">comment:{{ loop.index }}</a>
166166
</h3>
167167

eleventy.config.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,6 @@ module.exports = function (eleventyConfig) {
8686
})
8787

8888
// Filters
89-
eleventyConfig.addFilter('yearsAgo', (datetime) => {
90-
const date = new Date(datetime / 1000)
91-
const now = new Date()
92-
const years = now.getFullYear() - date.getFullYear()
93-
if (years > 0) {
94-
return `${years} year${years === 1 ? '' : 's'} ago`
95-
}
96-
return DateTime.fromJSDate(date, { zone: 'utc' }).toFormat('dd LLLL yyyy')
97-
})
98-
9989
eleventyConfig.addFilter('isImage', (filename) => {
10090
return /\.(jpg|jpeg|png|webp|gif|tiff|avif|svg)$/i.test(filename)
10191
})
@@ -113,10 +103,11 @@ module.exports = function (eleventyConfig) {
113103
return `${kilos.toFixed(1)} KB`
114104
})
115105

116-
eleventyConfig.addFilter('readableDate', (dateObj, format, zone) => {
106+
eleventyConfig.addFilter('readableDate', (datetime, format, zone) => {
117107
// Formatting tokens for Luxon: https://moment.github.io/luxon/#/formatting?id=table-of-tokens
118-
return DateTime.fromJSDate(dateObj, { zone: zone || 'utc' }).toFormat(
119-
format || 'dd LLLL yyyy'
108+
const date = new Date(datetime / 1000)
109+
return DateTime.fromJSDate(date, { zone: zone || 'utc' }).toFormat(
110+
format || 'LLLL dd, yyyy hh:mma z'
120111
)
121112
})
122113

public/css/ticket.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
.ticket-title {
4141
border-bottom: 1px solid #bbb;
42+
margin-top: 1em;
4243
padding-bottom: 0.25em;
4344
font-weight: bold;
4445
font-size: 1.1875rem;

0 commit comments

Comments
 (0)