Skip to content

Time (and Date) doesn't always have equivalents of DateTime methods #90

@ghost

Description

Encountered a few issues trying to fix the style for spy. Those seem relatively minor but each change needs a lot more reflexion than I expected.

Time.parse doesn't end up with the same time zone

The 00:00 timezone information is not parsed the same way. Time seems to ignore the time zone information from the argument in this case (local time zone is currently UTC-4):

[2] pry(main)> DateTime.parse('2017-08-08T15:00:00 00:00').utc.iso8601
=> "2017-08-08T15:00:00+00:00"
[3] pry(main)> Time.parse('2017-08-08T15:00:00 00:00').utc.iso8601
=> "2017-08-08T19:00:00Z"

In this case Time.zone.parse is a more suitable replacement for DateTime.rfc3339.

Time.iso8601 prints UTC time zone differently

[1] pry(main)> DateTime.parse('2017-08-08T15:00:00Z').iso8601
=> "2017-08-08T15:00:00+00:00"
[2] pry(main)> Time.parse('2017-08-08T15:00:00Z').iso8601
=> "2017-08-08T15:00:00Z"

This is mostly harmless, but sometimes makes tests fail.

Date.rfc3339 timezone information is lost

[4] pry(main)> DateTime.rfc3339('2002-10-02T10:00:00-05:00').to_time.utc
=> 2002-10-02 15:00:00 UTC
[5] pry(main)> Date.rfc3339('2002-10-02T10:00:00-05:00').to_time.utc
=> 2002-10-02 04:00:00 UTC

Again, Time.zone.parse is a more suitable replacement for DateTime.rfc3339.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions