New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cases assume they're not being run in Sydney #698

Closed
ghost opened this Issue Dec 23, 2012 · 4 comments

Comments

Projects
None yet
5 participants
@ghost
Copy link

ghost commented Dec 23, 2012

I ran the test suite for version 0.12.0 and got these failures:

In all three cases, the problem seems to be that a time in YAML Front Matter is being parsed as UTC and then formatted as a string using the system's time zone – UTC+11 for me – while the subsequent assertions assume that the system's time zone is closer to UTC.

@parkr

This comment has been minimized.

Copy link
Member

parkr commented Dec 25, 2012

Interesting, I'll take a look.

@ghost ghost assigned mojombo Dec 25, 2012

@ixti

This comment has been minimized.

Copy link
Member

ixti commented Dec 25, 2012

The problem is that when date is parsed by YAML and contains time, it will be represented by Time:

YAML.load('2012-12-25').is_a? Date # => true
YAML.load('2012-12-25 10:00:00').is_a? Time # => true

So when it reads this date and it contains not TZ, it assumes UTC.
Typecasting to String in it's turn returns date in local timezone.

Here's a simple example to better understand what's going on:

$ ruby -e 'require "yaml"; puts YAML.load("2012-12-31 23:30:00")'
2013-01-01 00:30:00 +0100
$ TZ=UTC ruby -e 'require "yaml"; puts YAML.load("2012-12-31 23:30:00")'
2012-12-31 23:30:00 +0000
$ TZ=America/Los_Angeles ruby -e 'require "yaml"; puts YAML.load("2012-12-31 23:30:00")'
2012-12-31 15:30:00 -0800
$ TZ=America/Los_Angeles ruby -e 'require "yaml"; puts YAML.load("2012-12-31 23:30:00 +02")'
2012-12-31 13:30:00 -0800
@chrisperelstein

This comment has been minimized.

Copy link

chrisperelstein commented Jan 10, 2013

I think the easiest way to deal with this (without "fixing" YAML.load) is to have dates in the YAML front matter be strings by quoting them. Then, YAML.load gives you a string that you can attempt to parse more flexibly in lib/jekyll/post.rb. It wouldn't be too hard to write something up to recognize a properly formatted date like iso8601 or rfc2822 and generate a Time object with the offset specified. The problem is the inconsistent behavior based on whether the date is quoted or not. I'd also like to see the TZInfo library used so the times could be overridden to always be in a configured timezone. This is something I could code up and do a pull request for, but I'm not sure what the preferred direction would be.

@parkr parkr referenced this issue Apr 13, 2013

Merged

Set Timezone in _config.yml #957

3 of 3 tasks complete
@parkr

This comment has been minimized.

Copy link
Member

parkr commented Apr 14, 2013

Seems to be a duplicate of #850. Closing.

@parkr parkr closed this Apr 14, 2013

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.