Преглед на файлове

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.
Zed преди 6 години
родител
ревизия
ec86a55b48
променени са 1 файла, в които са добавени 3 реда и са изтрити 1 реда
  1. 3 1
      src/parserutils.nim

+ 3 - 1
src/parserutils.nim

@@ -9,6 +9,8 @@ const
   htRegex = re"(^|[^A-z0-9-_./?])#([A-z0-9_]+)"
   htReplace = "$1<a href=\"/search?q=%23$2\">#$2</a>"
 
+let localTimezone = local()
+
 template `?`*(js: JsonNode): untyped =
   let j = js
   if j == nil: return
@@ -31,7 +33,7 @@ proc getCursor*(js: JsonNode): string =
 
 proc parseTime(time: string; f: static string; flen: int): Time =
   if time.len != flen: return
-  parseTime(time, f, utc())
+  parseTime(time, f, localTimezone).utc.toTime
 
 proc getDateTime*(js: JsonNode): Time =
   parseTime(js.getStr, "yyyy-MM-dd\'T\'HH:mm:ss\'Z\'", 20)