From d3fc1cdf9ca177c8b79ae7451d587a71da169dcc Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Tue, 1 Nov 2016 09:57:36 -0500 Subject: [PATCH] Fix incorrect ISO time format. An incorrect time format that was used in version 0.6 and prior. Version 0.7 between 1.0 support this format on read only and will write out the correct format (so they can be used to convert older timelines). --- ptk.nim | 22 ++++++++++++++++------ ptk.nimble | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ptk.nim b/ptk.nim index ba4e618..418bafc 100644 --- a/ptk.nim +++ b/ptk.nim @@ -19,12 +19,14 @@ let NO_MARK: Mark = ( time: fromSeconds(0).getLocalTime, summary: "", notes: "", tags: @[]) -const ISO_TIME_FORMAT = "yyyy:MM:dd'T'HH:mm:ss" +const ISO_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss" const TIME_FORMATS = @[ - "H:mm", "HH:mm", "H:mm:ss", "HH:mm:ss", - "yyyy:MM:dd'T'HH:mm:ss", "yyyy:MM:dd'T'HH:mm", - "yyyy:MM:dd HH:mm:ss", "yyyy:MM:dd HH:mm"] + "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-dd'T'HH:mm", "yyyy-MM-dd HH:mm", + "MM-dd'T'HH:mm:ss", "MM-dd HH:mm:ss", + "MM-dd'T'HH:mm", "MM-dd HH:mm", + "HH:mm:ss", "H:mm:ss", "H:mm", "HH:mm" ] #proc `$`*(mark: Mark): string = #return (($mark.uuid)[ @@ -62,9 +64,17 @@ proc loadTimeline(filename: string): Timeline = var timeline: Timeline = (name: timelineJson["name"].getStr(), marks: @[]) for markJson in timelineJson["marks"]: + + # TODO: an incorrect time format that was used in version 0.6 and prior. + # Version 0.7 between 1.0 support this format on read only and will write + # out the correct format (so they can be used to convert older timelines). + var time: TimeInfo + try: time = parse(markJson["time"].getStr(), ISO_TIME_FORMAT) + except: time = parse(markJson["time"].getStr(), "yyyy:MM:dd'T'HH:mm:ss") + timeline.marks.add(( id: parseUUID(markJson["id"].getStr()), - time: parse(markJson["time"].getStr(), ISO_TIME_FORMAT), + time: time, #parse(markJson["time"].getStr(), ISO_TIME_FORMAT), summary: markJson["summary"].getStr(), notes: markJson["notes"].getStr(), tags: markJson["tags"].getElems(@[]).map(proc (t: JsonNode): string = t.getStr()))) @@ -333,7 +343,7 @@ Options: let now = getLocalTime(getTime()) # Parse arguments - let args = docopt(doc, version = "ptk 0.6.0") + let args = docopt(doc, version = "ptk 0.7.0") if args["--echo-args"]: echo $args diff --git a/ptk.nimble b/ptk.nimble index c911a1d..5b5c915 100644 --- a/ptk.nimble +++ b/ptk.nimble @@ -1,6 +1,6 @@ # Package -version = "0.6.0" +version = "0.7.0" author = "Jonathan Bernard" description = "Personal Time Keeper" license = "MIT"