times.nim: remove code duplication
This commit is contained in:
parent
49667798eb
commit
82448b1304
1 changed files with 2 additions and 8 deletions
|
|
@ -514,14 +514,6 @@ when not defined(JS):
|
|||
# copying is needed anyway to provide reentrancity; thus
|
||||
# the conversion is not expensive
|
||||
|
||||
proc timeInfoToTime(timeInfo: TimeInfo): Time =
|
||||
var cTimeInfo = timeInfo # for C++ we have to make a copy,
|
||||
# because the header of mktime is broken in my version of libc
|
||||
result = mktime(timeInfoToTM(cTimeInfo))
|
||||
# mktime is defined to interpret the input as local time. As timeInfoToTM
|
||||
# does ignore the timezone, we need to adjust this here.
|
||||
result = Time(TimeImpl(result) - getTimezone() + timeInfo.timezone)
|
||||
|
||||
proc toTime(timeInfo: TimeInfo): Time =
|
||||
var cTimeInfo = timeInfo # for C++ we have to make a copy,
|
||||
# because the header of mktime is broken in my version of libc
|
||||
|
|
@ -530,6 +522,8 @@ when not defined(JS):
|
|||
# does ignore the timezone, we need to adjust this here.
|
||||
result = Time(TimeImpl(result) - getTimezone() + timeInfo.timezone)
|
||||
|
||||
proc timeInfoToTime(timeInfo: TimeInfo): Time = toTime(timeInfo)
|
||||
|
||||
const
|
||||
epochDiff = 116444736000000000'i64
|
||||
rateDiff = 10000000'i64 # 100 nsecs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue