YAML Front-Matter DateTime handling

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

YAML Front-Matter DateTime handling

Gerhard Poul
Hi,

I've noticed that when I specify a DateTime in YAML Front-Matter that
it gets picked up by the Posts extension, which is nice, but the
underlying YAML implementation seems to implement the spec
(http://yaml.org/type/timestamp.html) quite tightly which indicates
that every timestamp that has no specific timezone is assumed to be
UTC and is then converted to my local timezone, which is not what I
expected.

In addition when you specify a DateTime without seconds like
"2013-05-05 09:30", which is quite easily parsed by Time.parse(), is
not considered a string by the YAML implementation and is passed as a
string.

I think both of these behaviors, while technically correct for use in
a serialization format are not really intuitive when I'm using this
for writing blog posts manually :)

Regards,
Gerhard

---------------------------------------------------------------------
Archives: http://talk-archive.awestruct.org/
To unsubscribe, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: YAML Front-Matter DateTime handling

LightGuard
Administrator
I believe your pull request is good, at least it seems to be according to travis. Mind verifying?


On Fri, May 24, 2013 at 1:10 PM, Gerhard Poul <[hidden email]> wrote:
Hi,

I've noticed that when I specify a DateTime in YAML Front-Matter that
it gets picked up by the Posts extension, which is nice, but the
underlying YAML implementation seems to implement the spec
(http://yaml.org/type/timestamp.html) quite tightly which indicates
that every timestamp that has no specific timezone is assumed to be
UTC and is then converted to my local timezone, which is not what I
expected.

In addition when you specify a DateTime without seconds like
"2013-05-05 09:30", which is quite easily parsed by Time.parse(), is
not considered a string by the YAML implementation and is passed as a
string.

I think both of these behaviors, while technically correct for use in
a serialization format are not really intuitive when I'm using this
for writing blog posts manually :)

Regards,
Gerhard

---------------------------------------------------------------------
Archives: http://talk-archive.awestruct.org/
To unsubscribe, e-mail: [hidden email]




--
Reply | Threaded
Open this post in threaded view
|

Re: YAML Front-Matter DateTime handling

Gerhard Poul
Unfortunately the pull request only addresses an issue when mixing a
timestamp detected by Psych and converted to a Time class at the same
time as using strings in the date field that are then converted to
DateTime by the Page extension.

The following two items might be interesting to discuss further:

1) Moving the date-conversion layer out of the Page extension and into
a layer that handles the YAML loading for the rest of awestruct. I
think this might make it more user friendly and less error prone.

2) The conversion of timestamps detected by Psych and forced to be UTC
instead of local time is counter-intuitive. I'm not sure how to
address this. I think it might make sense for Psych to expose whether
UTC was actually specified in the loaded YAML or whether it was forced
to UTC so the application using Psych has a choice of what to do, but
that would require a change in Psych.

What do you think?

On Wed, May 29, 2013 at 4:36 AM, Jason Porter <[hidden email]> wrote:

> I believe your pull request is good, at least it seems to be according to
> travis. Mind verifying?
>
>
> On Fri, May 24, 2013 at 1:10 PM, Gerhard Poul <[hidden email]>
> wrote:
>>
>> Hi,
>>
>> I've noticed that when I specify a DateTime in YAML Front-Matter that
>> it gets picked up by the Posts extension, which is nice, but the
>> underlying YAML implementation seems to implement the spec
>> (http://yaml.org/type/timestamp.html) quite tightly which indicates
>> that every timestamp that has no specific timezone is assumed to be
>> UTC and is then converted to my local timezone, which is not what I
>> expected.
>>
>> In addition when you specify a DateTime without seconds like
>> "2013-05-05 09:30", which is quite easily parsed by Time.parse(), is
>> not considered a string by the YAML implementation and is passed as a
>> string.
>>
>> I think both of these behaviors, while technically correct for use in
>> a serialization format are not really intuitive when I'm using this
>> for writing blog posts manually :)
>>
>> Regards,
>> Gerhard
>>
>> ---------------------------------------------------------------------
>> Archives: http://talk-archive.awestruct.org/
>> To unsubscribe, e-mail: [hidden email]
>>
>
>
>
> --
> Jason Porter
> http://en.gravatar.com/lightguardjp

---------------------------------------------------------------------
Archives: http://talk-archive.awestruct.org/
To unsubscribe, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: YAML Front-Matter DateTime handling

LightGuard
Administrator
That may work, in the engine.rb file is where the site.yml and other yml files are loaded, you could take a look there.


On Wed, May 29, 2013 at 2:56 AM, Gerhard Poul <[hidden email]> wrote:
Unfortunately the pull request only addresses an issue when mixing a
timestamp detected by Psych and converted to a Time class at the same
time as using strings in the date field that are then converted to
DateTime by the Page extension.

The following two items might be interesting to discuss further:

1) Moving the date-conversion layer out of the Page extension and into
a layer that handles the YAML loading for the rest of awestruct. I
think this might make it more user friendly and less error prone.

2) The conversion of timestamps detected by Psych and forced to be UTC
instead of local time is counter-intuitive. I'm not sure how to
address this. I think it might make sense for Psych to expose whether
UTC was actually specified in the loaded YAML or whether it was forced
to UTC so the application using Psych has a choice of what to do, but
that would require a change in Psych.

What do you think?

On Wed, May 29, 2013 at 4:36 AM, Jason Porter <[hidden email]> wrote:
> I believe your pull request is good, at least it seems to be according to
> travis. Mind verifying?
>
>
> On Fri, May 24, 2013 at 1:10 PM, Gerhard Poul <[hidden email]>
> wrote:
>>
>> Hi,
>>
>> I've noticed that when I specify a DateTime in YAML Front-Matter that
>> it gets picked up by the Posts extension, which is nice, but the
>> underlying YAML implementation seems to implement the spec
>> (http://yaml.org/type/timestamp.html) quite tightly which indicates
>> that every timestamp that has no specific timezone is assumed to be
>> UTC and is then converted to my local timezone, which is not what I
>> expected.
>>
>> In addition when you specify a DateTime without seconds like
>> "2013-05-05 09:30", which is quite easily parsed by Time.parse(), is
>> not considered a string by the YAML implementation and is passed as a
>> string.
>>
>> I think both of these behaviors, while technically correct for use in
>> a serialization format are not really intuitive when I'm using this
>> for writing blog posts manually :)
>>
>> Regards,
>> Gerhard
>>
>> ---------------------------------------------------------------------
>> Archives: http://talk-archive.awestruct.org/
>> To unsubscribe, e-mail: [hidden email]
>>
>
>
>
> --
> Jason Porter
> http://en.gravatar.com/lightguardjp

---------------------------------------------------------------------
Archives: http://talk-archive.awestruct.org/
To unsubscribe, e-mail: [hidden email]




--