Skip to content

Commit

Permalink
Parse "Z" as UTC
Browse files Browse the repository at this point in the history
I think it is convenient to parse "Z" as UTC.
In addition, I guess this change should have been included
in the commit "dae8e5c97d47c4e594bf850f72d212f1c49dbff5".
  • Loading branch information
abicky committed May 10, 2020
1 parent fc7f480 commit 39bbe26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/strptime/strptime.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ strptime_exec0(void **pc, const char *fmt, const char *str, size_t slen,
int r;
size_t len;
if (*p0 == 'z' || *p0 == 'Z') {
gmtoff = 0;
gmtoff = INT_MAX-1;
ADD_PC(1);
END_INSN(z)
}
Expand Down
3 changes: 3 additions & 0 deletions spec/strptime_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
expect(Strptime.new("%z").exec("+09:00").utc_offset).to eq(32400)
expect(Strptime.new("%z").exec("+09:30").utc_offset).to eq(34200)
expect(Strptime.new("%z").exec("Z").utc_offset).to eq(0)
expect(Strptime.new("%z").exec("Z")).to be_utc
expect(Strptime.new("%z").exec("+00:00").utc_offset).to eq(0)
expect(Strptime.new("%z").exec("+00:00")).not_to be_utc
end

## from test/test_time.rb
Expand Down

0 comments on commit 39bbe26

Please sign in to comment.