diff --git a/Gemfile b/Gemfile index 70c1c553..a6190c93 100644 --- a/Gemfile +++ b/Gemfile @@ -86,7 +86,7 @@ group :jekyll_optional_dependencies do # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem # and associated library platforms :jruby, :mswin, :mingw, :x64_mingw do - gem "tzinfo", "~> 1.2" + gem "tzinfo", ENV["TZINFO_VERSION"] if ENV["TZINFO_VERSION"] gem "tzinfo-data" end end diff --git a/appveyor.yml b/appveyor.yml index 24ea983c..db721048 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,6 +13,12 @@ build: off environment: BUNDLE_WITHOUT: "benchmark:development" matrix: + - RUBY_FOLDER_VER: "26" + TZINFO_VERSION: "~> 1.2" + TEST_SUITE: "test" + - RUBY_FOLDER_VER: "26" + TZINFO_VERSION: "~> 2.0" + TEST_SUITE: "test" - RUBY_FOLDER_VER: "26" TEST_SUITE: "test" - RUBY_FOLDER_VER: "26" @@ -21,6 +27,12 @@ environment: TEST_SUITE: "profile-docs" - RUBY_FOLDER_VER: "26" TEST_SUITE: "memprof" + - RUBY_FOLDER_VER: "26" + TZINFO_VERSION: "~> 1.2" + TEST_SUITE: "cucumber" + - RUBY_FOLDER_VER: "26" + TZINFO_VERSION: "~> 2.0" + TEST_SUITE: "cucumber" - RUBY_FOLDER_VER: "26" TEST_SUITE: "cucumber" diff --git a/docs/_docs/installation/windows.md b/docs/_docs/installation/windows.md index eacd92c6..c7d77ed0 100644 --- a/docs/_docs/installation/windows.md +++ b/docs/_docs/installation/windows.md @@ -121,22 +121,14 @@ While 'new' blogs created with Jekyll v3.4 and greater, will have the following sites *will* have to update their `Gemfile` (and installed gems) to enable development on Windows: ```ruby -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem +# and associated library. +platforms :mingw, :x64_mingw, :mswin, :jruby do + gem "tzinfo", ">= 1", "< 3" + gem "tzinfo-data" +end ``` -
- Version 2.0 of the TZInfo library has introduced a change in how timezone offsets are calculated. - This will result in incorrect date and time for your posts when the site is built with Jekyll 3.x on Windows. -
-
- We therefore recommend that you lock the Timezone library to version 1.2 and above by listing
- gem 'tzinfo', '~> 1.2'
in your Gemfile
.
-
content for entry1.
\n built at 2013-04-09T09:22:00-10:00" in "_site/2013/04/09/entry1.html" And I should see "Post Layout:content for entry2.
\n built at 2013-04-09T13:14:00-10:00" in "_site/2013/04/09/entry2.html" + Scenario: Generate proper dates with explicitly set timezone (using non-half hour offset ) + Given I have a _layouts directory + And I have a page layout that contains "Page Layout: {{ site.posts.size }}" + And I have a post layout that contains "Post Layout: {{ content }} built at {{ page.date | date_to_xmlschema }}" + And I have an "index.html" page with layout "page" that contains "site index page" + And I have a configuration file with: + | key | value | + | timezone | Australia/Eucla | + And I have a _posts directory + And I have the following posts: + | title | date | layout | content | + | entry1 | 2013-04-09 23:22 +0400 | post | content for entry1. | + | entry2 | 2013-04-10 03:14 +0400 | post | content for entry2. | + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + And I should see "Page Layout: 2" in "_site/index.html" + And the "_site/2013/04/10/entry1.html" file should exist + And the "_site/2013/04/10/entry2.html" file should exist + And I should see "Post Layout:content for entry1.
\n built at 2013-04-10T04:07:00\+08:45" in "_site/2013/04/10/entry1.html" + And I should see "Post Layout:content for entry2.
\n built at 2013-04-10T07:59:00\+08:45" in "_site/2013/04/10/entry2.html" + Scenario: Limit the number of posts generated by most recent date Given I have a _posts directory And I have a configuration file with: diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 150b4aa7..f85026ba 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -92,7 +92,7 @@ module Jekyll # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem # and associated library. platforms :mingw, :x64_mingw, :mswin, :jruby do - gem "tzinfo", "~> 1.2" + gem "tzinfo", ">= 1", "< 3" gem "tzinfo-data" end diff --git a/lib/jekyll/utils/win_tz.rb b/lib/jekyll/utils/win_tz.rb index 9c55c42e..d6ffad43 100644 --- a/lib/jekyll/utils/win_tz.rb +++ b/lib/jekyll/utils/win_tz.rb @@ -11,64 +11,35 @@ module Jekyll # timezone - the IANA Time Zone specified in "_config.yml" # # Returns a string that ultimately re-defines ENV["TZ"] in Windows - def calculate(timezone) + def calculate(timezone, now = Time.now) External.require_with_graceful_fail("tzinfo") unless defined?(TZInfo) tz = TZInfo::Timezone.get(timezone) - difference = Time.now.to_i - tz.now.to_i + + # + # Use period_for_utc and utc_total_offset instead of + # period_for and observed_utc_offset for compatibility with tzinfo v1. + offset = tz.period_for_utc(now.getutc).utc_total_offset + # # POSIX style definition reverses the offset sign. # e.g. Eastern Standard Time (EST) that is 5Hrs. to the 'west' of Prime Meridian # is denoted as: # EST+5 (or) EST+05:00 # Reference: http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html - sign = difference.negative? ? "-" : "+" - offset = sign == "-" ? "+" : "-" unless difference.zero? - # - # convert the difference (in seconds) to hours, as a rational number, and perform - # a modulo operation on it. - modulo = modulo_of(rational_hour(difference)) - # - # Format the hour as a two-digit number. - # Establish the minutes based on modulo expression. - hh = format("%