Preserve original UTC timestamp

This commit is contained in:
Zed 2020-06-02 21:06:44 +02:00
parent 3dc85639f4
commit 77f03425ef
2 changed files with 6 additions and 6 deletions

View file

@ -96,10 +96,11 @@ proc getTweetTime*(tweet: Tweet): string =
tweet.time.format("h:mm tt' · 'MMM d', 'YYYY")
proc getShortTime*(tweet: Tweet): string =
let
now = now().utc
then = tweet.time.utc
since = now - then
let now = now()
var then = tweet.time.local()
then.utcOffset = 0
let since = now - then
if now.year != then.year:
result = tweet.time.format("d MMM yyyy")
@ -112,7 +113,6 @@ proc getShortTime*(tweet: Tweet): string =
elif since.inSeconds > 1:
result = $since.inSeconds & "s"
else:
# this shouldn't happen, but just in case
result = "now"
proc getLink*(tweet: Tweet; focus=true): string =

View file

@ -36,7 +36,7 @@ template getError*(js: JsonNode): Error =
template parseTime(time: string; f: static string; flen: int): Time =
if time.len != flen: return
parseTime(time, f, utc())
parse(time, f).toTime
proc getDateTime*(js: JsonNode): Time =
parseTime(js.getStr, "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'", 20)