From 0f87b1c9434116dfc738baff1b5360e3b28715c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Sun, 10 Jun 2018 13:36:04 +0200 Subject: [PATCH 1/2] Ensure time parser raises if timezone is missing --- spec/std/time/time_spec.cr | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/std/time/time_spec.cr b/spec/std/time/time_spec.cr index fb7e987c150b..0d3ffa09a76f 100644 --- a/spec/std/time/time_spec.cr +++ b/spec/std/time/time_spec.cr @@ -646,6 +646,15 @@ describe Time do time.location.fixed?.should be_true end + it "raises when time zone missing" do + expect_raises(Time::Format::Error, "Invalid timezone") do + Time.parse("", "%z") + end + expect_raises(Time::Format::Error, "Invalid timezone") do + Time.parse("123456+01:00", "%3N%z") + end + end + # TODO %Z # TODO %G # TODO %g From dadc1099cc92e4c75284bc634b8529321e304f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Mon, 11 Jun 2018 20:54:45 +0200 Subject: [PATCH 2/2] fix doc for %L in Time::Format --- src/time/format.cr | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/time/format.cr b/src/time/format.cr index 37670c750ff6..65355fd57181 100644 --- a/src/time/format.cr +++ b/src/time/format.cr @@ -30,12 +30,12 @@ require "./format/parser" # * **%j**: day of year, zero padded (001, 002, ..., 365) # * **%k**: hour of the day, 24-hour clock, blank padded (" 0", " 1", ..., "24") # * **%l**: hour of the day, 12-hour clock, blank padded (" 0", " 1", ..., "12") -# * **%L**: milliseconds, zero padded (000, 001, ..., 999) +# * **%L**: milliseconds, zero padded (000, 001, ..., 999) (same as **%3N**) # * **%m**: month number, zero padded (01, 02, ..., 12) # * **%_m**: month number, blank padded (" 1", " 2", ..., "12") # * **%-m**: month number (1, 2, ..., 12) # * **%M**: minute, zero padded (00, 01, 02, ..., 59) -# * **%3N**, **%L**: milliseconds, zero padded (000, 001, ..., 999) +# * **%3N**: milliseconds, zero padded (000, 001, ..., 999) (same as **%L**) # * **%6N**: microseconds, zero padded (000000, 000001, ..., 999999) # * **%9N**: nanoseconds, zero padded (000000000, 000000001, ..., 999999999) # * **%N**: second fraction, zero padded. (Same as `%9N` but may consume more than 9 digits while parsing)