Skip to content
Closed
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 @@ -624,6 +624,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
3 changes: 2 additions & 1 deletion src/http/common.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
{% end %}

module HTTP
private DATE_PATTERNS = {"%a, %d %b %Y %H:%M:%S %z", "%d %b %Y %H:%M:%S %z", "%A, %d-%b-%y %H:%M:%S %z", "%a %b %e %H:%M:%S %Y"}
private DATE_PATTERNS = {"%a, %d %b %Y %H:%M:%S %z", "%d %b %Y %H:%M:%S %z", "%A, %d-%b-%y %H:%M:%S %z", "%a %b %e %H:%M:%S %Y",
"%a, %d %b %Y %H:%M:%S GMT", "%d %b %Y %H:%M:%S GMT", "%A, %d-%b-%y %H:%M:%S GMT", "%a %b %e %H:%M:%S %Y"}

# :nodoc:
MAX_HEADER_SIZE = 16_384
Expand Down
2 changes: 2 additions & 0 deletions src/time/format/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ struct Time::Format
@reader.pos = pos
end
end
else
raise "Invalid timezone"
end
end

Expand Down