Upgrade WinTZ utility to use TZInfo-2.0 (#7521)
Merge pull request 7521
This commit is contained in:
parent
4e24a460ae
commit
13cbef4221
8
Gemfile
8
Gemfile
|
@ -80,8 +80,12 @@ group :jekyll_optional_dependencies do
|
||||||
gem "yajl-ruby", "~> 1.4"
|
gem "yajl-ruby", "~> 1.4"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
gem "tzinfo-data", :platforms => [:mingw, :mswin, :x64_mingw, :jruby]
|
# and associated library
|
||||||
|
install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
|
||||||
|
gem "tzinfo", "~> 2.0"
|
||||||
|
gem "tzinfo-data"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -46,6 +46,21 @@ you can invoke *`Liquid::Template`* directly:
|
||||||
+ template = Liquid::Template.parse(content)
|
+ template = Liquid::Template.parse(content)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Timezone in Windows
|
||||||
|
|
||||||
|
Timezone handling for Jekyll on Windows now requires `tzinfo-2.0` and above.
|
||||||
|
Simply add / update the gem listing in your `Gemfile`:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
# Gemfile
|
||||||
|
|
||||||
|
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||||
|
# and associated library.
|
||||||
|
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
||||||
|
gem "tzinfo", "~> 2.0"
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Exclusion changes
|
### Exclusion changes
|
||||||
|
|
|
@ -88,8 +88,14 @@ module Jekyll
|
||||||
group :jekyll_plugins do
|
group :jekyll_plugins do
|
||||||
gem "jekyll-feed", "~> 0.6"
|
gem "jekyll-feed", "~> 0.6"
|
||||||
end
|
end
|
||||||
# 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.
|
||||||
|
install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
|
||||||
|
gem "tzinfo", "~> 2.0"
|
||||||
|
gem "tzinfo-data"
|
||||||
|
end
|
||||||
|
|
||||||
# Performance-booster for watching directories on Windows
|
# Performance-booster for watching directories on Windows
|
||||||
gem "wdm", "~> 0.1.1", :install_if => Gem.win_platform?
|
gem "wdm", "~> 0.1.1", :install_if => Gem.win_platform?
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,20 @@ module Jekyll
|
||||||
# Returns a string that ultimately re-defines ENV["TZ"] in Windows
|
# Returns a string that ultimately re-defines ENV["TZ"] in Windows
|
||||||
def calculate(timezone)
|
def calculate(timezone)
|
||||||
External.require_with_graceful_fail("tzinfo") unless defined?(TZInfo)
|
External.require_with_graceful_fail("tzinfo") unless defined?(TZInfo)
|
||||||
tz = TZInfo::Timezone.get(timezone)
|
difference = TZInfo::Timezone.get(timezone).now.utc_offset
|
||||||
difference = Time.now.to_i - tz.now.to_i
|
|
||||||
#
|
#
|
||||||
# POSIX style definition reverses the offset sign.
|
# POSIX style definition reverses the offset sign.
|
||||||
# e.g. Eastern Standard Time (EST) that is 5Hrs. to the 'west' of Prime Meridian
|
# e.g. Eastern Standard Time (EST) that is 5Hrs. to the 'west' of Prime Meridian
|
||||||
# is denoted as:
|
# is denoted as:
|
||||||
# EST+5 (or) EST+05:00
|
# EST+5 (or) EST+05:00
|
||||||
# Reference: http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
|
# Reference: http://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
|
||||||
sign = difference.negative? ? "-" : "+"
|
if difference.negative?
|
||||||
offset = sign == "-" ? "+" : "-" unless difference.zero?
|
offset = "-"
|
||||||
|
sign = "+"
|
||||||
|
else
|
||||||
|
offset = "+"
|
||||||
|
sign = "-"
|
||||||
|
end
|
||||||
#
|
#
|
||||||
# convert the difference (in seconds) to hours, as a rational number, and perform
|
# convert the difference (in seconds) to hours, as a rational number, and perform
|
||||||
# a modulo operation on it.
|
# a modulo operation on it.
|
||||||
|
|
Loading…
Reference in New Issue