mirror of
https://gitlab.com/OpenAlt/OpenAltRO/openalt_ro.git
synced 2026-11-23 23:29:14 +00:00
Added new events and more
This commit is contained in:
parent
9ea7891f73
commit
e820431d0c
6 changed files with 93 additions and 34 deletions
|
|
@ -1,9 +1,19 @@
|
|||
<%
|
||||
<% {
|
||||
const posted = new Date(date);
|
||||
const now = new Date();
|
||||
const year = 365 * 24 * 60 * 60 * 1000;
|
||||
const format = (now - posted) < year ?
|
||||
{ day: 'numeric', month: 'long', hour: 'numeric', minute: 'numeric', hour12: true } :
|
||||
{ day: 'numeric', month: 'long', year: 'numeric', hour: 'numeric', minute: 'numeric', hour12: true };
|
||||
const day = ((d => {
|
||||
if (d > 3 && d < 21) return d + 'th';
|
||||
switch (d % 10) {
|
||||
case 1: return d + 'st';
|
||||
case 2: return d + 'nd';
|
||||
case 3: return d + 'rd';
|
||||
default: return d + 'th';
|
||||
}
|
||||
})(posted.getDate()));
|
||||
|
||||
const options = now.getFullYear() === posted.getFullYear()
|
||||
? { month: 'long', hour: 'numeric', minute: 'numeric', hour12: true }
|
||||
: { year: 'numeric', month: 'long'};
|
||||
%>
|
||||
<%= posted.toLocaleString('en-US', format ) %>
|
||||
<%= day %> <%= posted.toLocaleString('en-US', options).replace(/^(\d+)\s/, '') %>
|
||||
<% } %>
|
||||
Loading…
Add table
Add a link
Reference in a new issue