2016-02-07 20:48:43 +00:00
|
|
|
import times
|
|
|
|
|
|
|
|
proc fixTime(p0: cstring): ptr clonglong {. importc, dynlib: "./gotime.so", noSideEffect .}
|
|
|
|
|
|
|
|
proc parseTime*(inp: string): TimeInfo =
|
|
|
|
let
|
|
|
|
cst = inp.cstring
|
|
|
|
res = cst.fixTime
|
|
|
|
|
|
|
|
if res == nil:
|
|
|
|
raise newException(ValueError, "Invalid time passed to this thing")
|
|
|
|
|
2016-02-08 02:51:41 +00:00
|
|
|
let
|
|
|
|
resdep = res[]
|
|
|
|
restime = resdep.fromSeconds
|
|
|
|
|
|
|
|
return restime.timeToTimeInfo
|
2016-02-07 20:48:43 +00:00
|
|
|
|
|
|
|
when isMainModule:
|
|
|
|
let myTime = fixTime("2006-01-02T15:04:05.000000-07:00")
|
|
|
|
|
|
|
|
if myTime == nil:
|
|
|
|
quit "lol failed"
|
|
|
|
|
|
|
|
echo myTime[]
|
|
|
|
|
|
|
|
echo parseTime("2006-01-02T15:04:05-07:00")
|