Fix timestamp parsing in non-UTC timezones
Twitter always has +0000 in the timestamp despite being relative to your IP geolocation. Shame on you, Twitter.
This commit is contained in:
parent
177e119441
commit
ec86a55b48
|
@ -9,6 +9,8 @@ const
|
||||||
htRegex = re"(^|[^A-z0-9-_./?])#([A-z0-9_]+)"
|
htRegex = re"(^|[^A-z0-9-_./?])#([A-z0-9_]+)"
|
||||||
htReplace = "$1<a href=\"/search?q=%23$2\">#$2</a>"
|
htReplace = "$1<a href=\"/search?q=%23$2\">#$2</a>"
|
||||||
|
|
||||||
|
let localTimezone = local()
|
||||||
|
|
||||||
template `?`*(js: JsonNode): untyped =
|
template `?`*(js: JsonNode): untyped =
|
||||||
let j = js
|
let j = js
|
||||||
if j == nil: return
|
if j == nil: return
|
||||||
|
@ -31,7 +33,7 @@ proc getCursor*(js: JsonNode): string =
|
||||||
|
|
||||||
proc parseTime(time: string; f: static string; flen: int): Time =
|
proc parseTime(time: string; f: static string; flen: int): Time =
|
||||||
if time.len != flen: return
|
if time.len != flen: return
|
||||||
parseTime(time, f, utc())
|
parseTime(time, f, localTimezone).utc.toTime
|
||||||
|
|
||||||
proc getDateTime*(js: JsonNode): Time =
|
proc getDateTime*(js: JsonNode): Time =
|
||||||
parseTime(js.getStr, "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'", 20)
|
parseTime(js.getStr, "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'", 20)
|
||||||
|
|
Loading…
Reference in New Issue