Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions spec/std/time/time_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/time/format.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down