Browse Source

use UTC in the database

master
Fr3deric 7 years ago
parent
commit
45a160e1be
  1. 11
      journalmarks/journalmarks.py
  2. 4
      journalmarks/templates/overview.html

11
journalmarks/journalmarks.py

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
import re
import json
import pytz
import random
import string
import hashlib
@ -32,7 +33,7 @@ class AccessToken(db_wrapper.Model): @@ -32,7 +33,7 @@ class AccessToken(db_wrapper.Model):
class Journalmark(db_wrapper.Model):
user = ForeignKeyField(User, backref='journalmarks')
created = DateTimeField(default=datetime.datetime.now())
created = DateTimeField(default=datetime.datetime.utcnow)
tag = CharField(unique=True)
content = CharField()
@ -87,7 +88,7 @@ def process_registration(): @@ -87,7 +88,7 @@ def process_registration():
with db_wrapper.database.atomic():
u = User(username=username, password=password_hash)
at.redeemed = datetime.datetime.now()
at.redeemed = datetime.datetime.utcnow()
u.save()
at.save()
return json.dumps('ok')
@ -194,7 +195,11 @@ def overview_get_journalmarks(): @@ -194,7 +195,11 @@ def overview_get_journalmarks():
content = json.loads(j.content)
except ValueError:
content = None
ret.append({'created': j.created.isoformat(), 'tag': j.tag, 'content': content})
ret.append({
'created': pytz.utc.localize(j.created).isoformat(),
'tag': j.tag,
'content': content
})
return json.dumps(ret)

4
journalmarks/templates/overview.html

@ -18,7 +18,9 @@ function run() { @@ -18,7 +18,9 @@ function run() {
var p = document.getElementById('prototype');
var n = p.cloneNode(true);
n.id = 'journalmark_' + j.tag;
n.getElementsByClassName('date')[0].innerText = j.created;
var created = new Date(j.created);
console.log(created);
n.getElementsByClassName('date')[0].innerText = created.getDate().toString() + '.' + (created.getMonth()+1).toString() + '.' + created.getFullYear().toString();
n.getElementsByClassName('tag')[0].innerText = j.tag;
n.getElementsByClassName('tag')[0].href = '/' + j.tag;
n.getElementsByClassName('url')[0].innerText = 'decrypting...';

Loading…
Cancel
Save