From 2509c08d3441bd2c98386f69d92005653d97186f Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Wed, 30 May 2012 22:35:43 +0100 Subject: [PATCH 1/2] Marshal now works with nil strings. Timezone and tzname vars are not public any more in the times module. --- lib/core/typeinfo.nim | 3 ++- lib/pure/times.nim | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/core/typeinfo.nim b/lib/core/typeinfo.nim index 9cc8e4dfd2..ca2b68cc3f 100755 --- a/lib/core/typeinfo.nim +++ b/lib/core/typeinfo.nim @@ -479,7 +479,8 @@ proc setBiggestFloat*(x: TAny, y: biggestFloat) = proc getString*(x: TAny): string = ## retrieve the string value out of `x`. `x` needs to represent a string. assert x.rawtype.kind == tyString - result = cast[ptr string](x.value)[] + if not isNil(cast[ptr pointer](x.value)[]): + result = cast[ptr string](x.value)[] proc setString*(x: TAny, y: string) = ## sets the string value of `x`. `x` needs to represent a string. diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 327dc91875..2070a39d8c 100755 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -26,8 +26,8 @@ type dMon, dTue, dWed, dThu, dFri, dSat, dSun var - timezone* {.importc, header: "".}: int - tzname* {.importc, header: "" .}: array[0..1, cstring] + timezone {.importc, header: "".}: int + tzname {.importc, header: "" .}: array[0..1, cstring] when defined(posix): type From ec39788b41949b10c44531271162ed5ea5ef0d1f Mon Sep 17 00:00:00 2001 From: Dominik Picheta Date: Wed, 30 May 2012 23:22:09 +0100 Subject: [PATCH 2/2] Fixed times.format handling of month numbers. --- lib/pure/times.nim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pure/times.nim b/lib/pure/times.nim index 2070a39d8c..4cb873b1ca 100755 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -580,11 +580,11 @@ proc format*(info: TTimeInfo, f: string): string = result.add('0') result.add($info.minute) of "M": - result.add($(int(info.month))) + result.add($(int(info.month)+1)) of "MM": if int(info.month) < 10: result.add('0') - result.add($(int(info.month))) + result.add($(int(info.month)+1)) of "MMM": result.add(($info.month)[0..2]) of "MMMM":