Skip to content

time: Parse unable to handle timezone offsets with seconds (+00:34:08) #4934

@gopherbot

Description

@gopherbot

by ulf@nhumi.com:

Trying to parse a time string like "0001-01-01 00:34:08+00:34:08" with the
pattern "2006-01-02 15:04:05-07:00:00" fails with a: cannot parse ""
as ":00". See http://play.golang.org/p/QFdTQ53Wol for small test case.
Removing the seconds from the pattern and time string works. 

The time string seem to be legitimate enough according to
http://en.wikipedia.org/wiki/Zoneinfo where America/New_York as an offset with seconds
before 1883-11-18

Zone America/New_York   -4:56:02 -      LMT     1883 Nov 18 12:03:58

I ran into this storing a Time struct in postgres as a timestamp with time zone. In my
timezone I get "0001-01-01 00:34:08+00:34:08" storing the result of
Format(time.RFC3339Nano) on an empty Time struct.

I'd be happy to help out fixing this but as my knowledge of time issues is rather
limited I'm not sure if it's only a matter of making time/format.go:nextStdChunk handle
the seconds in case '-'?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions