summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-03-11 01:47:34 -0700
committerGitHub <noreply@github.com>2020-03-11 09:47:34 +0100
commit281e02fc797ad98013ab29525256ba2ffdaf96a7 (patch)
tree2201b537b6ebc6556c45a32dfd5ae9fcee8f1b4a /lib
parentf5f9243cc05cae998e4380a347da8e93ac547dd4 (diff)
downloadNim-281e02fc797ad98013ab29525256ba2ffdaf96a7.tar.gz
fixes #13558: toDateTime buggy on 29th, 30th and 31th of each month; breaking change: do not use `now` to compute result, was undocumented and non-sensical (#13565)
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/times.nim16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/pure/times.nim b/lib/pure/times.nim
index 92b6cd3b7..45ed6dd67 100644
--- a/lib/pure/times.nim
+++ b/lib/pure/times.nim
@@ -2248,19 +2248,9 @@ proc parsePattern(input: string, pattern: FormatPattern, i: var int,
 
 proc toDateTime(p: ParsedTime, zone: Timezone, f: TimeFormat,
                 input: string): DateTime =
-  var month = mJan
-  var year: int
-  var monthday: int
-  # `now()` is an expensive call, so we avoid it when possible
-  (year, month, monthday) =
-    if p.year.isNone or p.month.isNone or p.monthday.isNone:
-      let n = now()
-      (p.year.get(n.year),
-        p.month.get(n.month.int).Month,
-        p.monthday.get(n.monthday))
-    else:
-      (p.year.get(), p.month.get().Month, p.monthday.get())
-
+  var year = p.year.get(0)
+  var month = p.month.get(1).Month
+  var monthday = p.monthday.get(1)
   year =
     case p.era
     of eraUnknown: