aboutsummaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2023-10-07 20:19:06 -0400
committertdro <tdro@noreply.example.com>2023-10-07 20:19:06 -0400
commitc83c49b0e18f0593a62a8a7754d1ff49ac097289 (patch)
treeecf67e580ce99de31816573afd88fdff5e57bfcb /assets/js
parent6f2f44c7ff0e3ff8ffd4e6bb394a0b39c0f89adf (diff)
downloadcanory-c83c49b0e18f0593a62a8a7754d1ff49ac097289.tar.gz
canory-c83c49b0e18f0593a62a8a7754d1ff49ac097289.tar.bz2
canory-c83c49b0e18f0593a62a8a7754d1ff49ac097289.zip
themes/default: Make time and dates consistent
Don't mix local time with UTC and fix future date calculation
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/index.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/assets/js/index.js b/assets/js/index.js
index 72e6736..4ae6d7c 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -566,10 +566,10 @@
try {
const time = new Date(element.dateTime) || new Date();
const interval = (new Date().getTime() - time.getTime()) / 1000;
- const seconds = Math.floor(interval);
- const minutes = Math.floor(seconds / 60);
- const hours = Math.floor(minutes / 60);
- const days = Math.floor(hours / 24);
+ const seconds = Math.round(interval);
+ const minutes = Math.round(seconds / 60);
+ const hours = Math.round(minutes / 60);
+ const days = Math.round(hours / 24);
const past = Math.sign(seconds) === 1;
const future = Math.sign(seconds) === -1;
if (past) {
@@ -582,21 +582,21 @@
if (hours <= 48) {
return element.textContent = relative.format(-1 * hours, "hour");
}
- if (days <= 60) {
+ if (days <= 7) {
return element.textContent = relative.format(-1 * days, "day");
}
}
if (future) {
- if (-1 * days >= 60) {
+ if (-1 * days >= 4) {
return element.textContent = relative.format(-1 * days, "day");
}
- if (-1 * hours >= 48) {
+ if (-1 * hours >= 3) {
return element.textContent = relative.format(-1 * hours, "hour");
}
- if (-1 * minutes >= 120) {
+ if (-1 * minutes >= 2) {
return element.textContent = relative.format(-1 * minutes, "minute");
}
- if (-1 * seconds >= 0) {
+ if (-1 * seconds >= 1) {
return element.textContent = relative.format(-1 * seconds, "second");
}
}