-
Notifications
You must be signed in to change notification settings - Fork 8
Now generating the expiry via javascript and showing local time #77
Conversation
This pull request introduces 1 alert when merging f00935e into f3e254e - view on LGTM.com new alerts:
|
<script type="text/javascript"> | ||
document.addEventListener('DOMContentLoaded', function(){ | ||
const expiry = new Date().addHours(24); | ||
document.getElementById('expiry').innerHTML = expiry.toLocaleString('{{ LANGUAGE_CODE }}'); | ||
}, false); | ||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this looks clean.
We'd like to keep a similar format as we had before though (I know vanilla JS date formatting is awful), so I'm not sure what's the cheapest solution here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my first reflex, but the latest version of the (official) CDN for date-fns was 1.9 (4 years ago). unpkg does seem to have a good up to date version (2.14) so I will make the switch. Thanks!
e577634
to
32dc679
Compare
The logic was making our template really complex, so pull it into a separate includes file. Did it progressively-enhanced, so if Javascript fails to run, it will still show the time and date in EDT.
32dc679
to
8493f3e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated it, moved the code to a new includes file. Gonna merge.
Now generating the expiry time in javascript and adding 24 h. Also displaying the local time in both french and english format.