Switched to keeping time with UTC for easier timezones

Removed useless JS
This commit is contained in:
Michał 2023-03-08 21:58:58 +00:00
parent 56c82513ba
commit b5bc0ec50c
5 changed files with 21 additions and 27 deletions

View file

@ -143,7 +143,7 @@ def upload():
# Save to database
try:
query = db.Posts(author_id = g.user.id,
created_at = dt.now(),
created_at = dt.utcnow(),
file_name = img_name+'.'+img_ext,
file_type = img_ext,
image_exif = img_exif,

View file

@ -100,7 +100,7 @@ def register():
register_user = db.Users(username=username,
email=email,
password=generate_password_hash(password),
created_at=dt.now())
created_at=dt.utcnow())
db_session.add(register_user)
db_session.commit()
except exc.IntegrityError:
@ -148,7 +148,7 @@ def login():
ip_address=request.remote_addr,
user_agent=request.user_agent.string,
active=True,
created_at=dt.now())
created_at=dt.utcnow())
db_session.add(session_query)
db_session.commit()

View file

@ -1,7 +1,6 @@
"""
Onlylegs Gallery - Routing
"""
import os
from datetime import datetime as dt
from flask import Blueprint, render_template, current_app, request, g

View file

@ -1,24 +1,6 @@
let navToggle = true;
document.onscroll = function() {
try {
document.querySelector('.background-decoration').style.opacity = `${1 - window.scrollY / 621}`;
document.querySelector('.background-decoration').style.top = `-${window.scrollY / 5}px`;
} catch (e) {
// Do nothing if banner not found
}
try {
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
document.querySelector('.banner').classList = 'banner banner-scrolled';
} else {
document.querySelector('.banner').classList = 'banner';
}
}
catch (e) {
// Do nothing if banner not found
}
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 20) {
document.querySelector('.jumpUp').classList = 'jumpUp jumpUp--show';
} else {
@ -35,9 +17,21 @@ function imgFade(obj) {
$(obj).animate({opacity: 1}, 250);
}
var times = document.getElementsByClassName('time');
for (var i = 0; i < times.length; i++) {
var time = times[i].innerHTML;
var date = new Date(time);
times[i].innerHTML = date.toLocaleString('en-GB');
let times = document.getElementsByClassName('time');
for (let i = 0; i < times.length; i++) {
// Remove milliseconds
const raw = times[i].innerHTML.split('.')[0];
// Parse YYYY-MM-DD HH:MM:SS to Date object
const time = raw.split(' ')[1]
const date = raw.split(' ')[0].split('-');
// Format to YYYY/MM/DD HH:MM:SS
let formatted = date[0] + '/' + date[1] + '/' + date[2] + ' ' + time + ' UTC';
// Convert to UTC Date object
let dateTime = new Date(formatted);
// Convert to local time
times[i].innerHTML = dateTime.toLocaleDateString() + ' ' + dateTime.toLocaleTimeString();
}

View file

@ -183,3 +183,4 @@
align-items: center
border-radius: $rad
border: 1px solid $white