forked from jekyll/jekyll
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support both tzinfo v1 and v2. Support non-half hour offsets.
Use the defined offset (in a v1 and v2 compatible way) instead of determining the offset from the difference between local time and UTC. Change the minutes calculation to allow for time zones that don't use hour or half hour offsets (e.g. Australia/Eucla's UTC+08:45). Resolves jekyll#8516.
- Loading branch information
Showing
5 changed files
with
57 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require "helper" | ||
|
||
class TestWinTz < JekyllUnitTest | ||
[["America/New_York", "WTZ+05:00"], ["Europe/Paris", "WTZ-01:00"]].each do |timezone, expected| | ||
should "use base offset in winter for #{timezone}" do | ||
result = Jekyll::Utils::WinTZ.calculate(timezone, Time.utc(2021, 1, 1)) | ||
assert_equal expected, result | ||
end | ||
end | ||
|
||
[["America/New_York", "WTZ+04:00"], ["Europe/Paris", "WTZ-02:00"]].each do |timezone, expected| | ||
should "apply DST in summer for #{timezone}" do | ||
result = Jekyll::Utils::WinTZ.calculate(timezone, Time.utc(2021, 7, 1)) | ||
assert_equal expected, result | ||
end | ||
end | ||
|
||
[["Australia/Eucla", "WTZ-08:45"], ["Pacific/Marquesas", "WTZ+09:30"]].each do |timezone, expected| | ||
should "handle non zero minutes for #{timezone}" do | ||
result = Jekyll::Utils::WinTZ.calculate(timezone, Time.utc(2021, 1, 1)) | ||
assert_equal expected, result | ||
end | ||
end | ||
|
||
should "return zero for UTC" do | ||
result = Jekyll::Utils::WinTZ.calculate("UTC") | ||
assert_equal "WTZ+00:00", result | ||
end | ||
end |