Skip to content

Commit 7fb2ca9

Browse files
committed
feat: render deployment time in browser timezone via <time> + JS
1 parent 9308fe0 commit 7fb2ca9

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎internal/http/templates/apps_detail.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ <h3>Deployment History</h3>
128128
<tbody>
129129
{{range .Deployments}}
130130
<tr>
131-
<td style="white-space:nowrap">{{.CreatedAt.Format "2006-01-02 15:04:05"}}</td>
131+
<td style="white-space:nowrap"><time datetime="{{.CreatedAt.Format "2006-01-02T15:04:05Z"}}">{{.CreatedAt.Format "2006-01-02 15:04:05"}}</time></td>
132132
<td><span class="badge badge-{{.Status}}">{{or .Status "unknown"}}</span></td>
133133
<td style="white-space:nowrap">{{if .CommitSHA}}{{.CommitSHA}}{{else}}-{{end}}</td>
134134
<td style="max-width:250px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="{{.Log}}">{{.Log}}</td>

‎internal/http/templates/layout.html‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,5 +282,11 @@
282282
b.textContent = isDark ? '☾' : '☀';
283283
localStorage.setItem('dockify-theme', isDark ? 'dark' : 'light');
284284
}
285+
document.querySelectorAll('time[datetime]').forEach(function(el){
286+
var d = new Date(el.getAttribute('datetime'));
287+
if (isNaN(d)) return;
288+
var p=function(n){return String(n).padStart(2,'0');};
289+
el.textContent = d.getFullYear()+'-'+p(d.getMonth()+1)+'-'+p(d.getDate())+' '+p(d.getHours())+':'+p(d.getMinutes())+':'+p(d.getSeconds());
290+
});
285291
</script>
286292
{{end}}

0 commit comments

Comments
 (0)