2 Commits
0.5.0 ... 0.5.2

2 changed files with 11 additions and 15 deletions

View File

@ -4,22 +4,19 @@ const zeroTime = fromUnix(0)
const ISO_8601_FORMATS = @[ const ISO_8601_FORMATS = @[
"yyyy-MM-dd'T'HH:mm:ssz", "yyyy-MM-dd'T'HH:mm:ssz",
"yyyy-MM-dd'T'HH:mm:sszzz", "yyyy-MM-dd'T'HH:mm:sszzz",
"yyyy-MM-dd'T'HH:mm:ss'.'fffzzz" "yyyy-MM-dd'T'HH:mm:ss'.'fffzzz",
"yyyy-MM-dd HH:mm:ssz",
"yyyy-MM-dd HH:mm:sszzz",
"yyyy-MM-dd HH:mm:ss'.'fffzzz"
] ]
proc format*(ti: TimeInterval, fmt: string): string = proc format*(ti: TimeInterval, fmt: string): string =
let info = (fromUnix(0) + ti).utc let info = (zeroTime + ti).utc
return info.format(fmt) return info.format(fmt)
# Will be deprecated in Nim 0.18.1 as it will exist in the standard times module. proc format*(d: Duration, fmt: string): string =
proc `-`*(a, b: DateTime): Duration {.deprecated} = let info = (fromUnix(0) + d).utc
return times.`-`(a,b) return info.format(fmt)
proc `<`*(a, b: DateTime): bool {.deprecated} =
return times.`<`(a,b)
proc `<=`*(a, b: DateTime): bool {.deprecated} =
return times.`<=`(a,b)
proc `<`*(a, b: TimeInterval): bool = proc `<`*(a, b: TimeInterval): bool =
return (zeroTime + a) < (zeroTime + b) return (zeroTime + a) < (zeroTime + b)

View File

@ -1,11 +1,10 @@
# Package # Package
version = "0.5.0" version = "0.5.2"
author = "Jonathan Bernard" author = "Jonathan Bernard"
description = "Utility methods to fill in the lacking time support in Nim\'s stdlib. This is holding me over until I can write a proper time module for the stdlib and submit it." description = "Utility methods to fill in the lacking time support in Nim\'s stdlib."
license = "BSD3" license = "BSD3"
# Dependencies # Dependencies
requires "nim >= 0.19.0" requires "nim >= 1.0.0"