fix a bug in time parsing

This commit is contained in:
Christine Dodrill 2016-02-07 18:51:41 -08:00
parent 47ace0e4c4
commit 87f1cfe1b1
3 changed files with 10 additions and 6 deletions

View File

@ -10,7 +10,11 @@ proc parseTime*(inp: string): TimeInfo =
if res == nil: if res == nil:
raise newException(ValueError, "Invalid time passed to this thing") raise newException(ValueError, "Invalid time passed to this thing")
return res[].fromSeconds.timeToTimeInfo let
resdep = res[]
restime = resdep.fromSeconds
return restime.timeToTimeInfo
when isMainModule: when isMainModule:
let myTime = fixTime("2006-01-02T15:04:05.000000-07:00") let myTime = fixTime("2006-01-02T15:04:05.000000-07:00")

View File

@ -1,8 +1,6 @@
package main package main
import ( import "time"
"time"
)
import "C" import "C"

View File

@ -74,5 +74,7 @@ proc updateTweetsOnce*() {. gcsafe .} =
for tweet in tweets.items(): for tweet in tweets.items():
try: try:
db.exec(sql"insert into tweets values(null, ?, ?, ?);", username, tweet.date.timeInfoToTime().toSeconds().int(), tweet.message) db.exec(sql"insert into tweets values(null, ?, ?, ?);", username, tweet.date.timeInfoToTime().toSeconds().int(), tweet.message)
except: discard except:
except: discard echo getCurrentExceptionMsg()
except:
echo getCurrentExceptionMsg()