Skip to content
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

Decoder: support all three kinds of TOML dates #96

Closed
jmelfi opened this issue Oct 2, 2015 · 1 comment
Closed

Decoder: support all three kinds of TOML dates #96

jmelfi opened this issue Oct 2, 2015 · 1 comment

Comments

@jmelfi
Copy link

jmelfi commented Oct 2, 2015

Currently datetime is having an issue with being able to be rendered as in the v0.4.0 spec. If you use a time that does not use UTC (e.g. doesn't have a 'Z' at the end) you get a failure.

1979-05-27T07:32:00Z will convert properly but 1979-05-27T07:32:00-08:00 will not.

I hazard a guess that this ties to the parse.go mapping Datetime

    case itemDatetime:
        t, err := time.Parse("2006-01-02T15:04:05Z", it.val)
        if err != nil {
            p.bug("Expected Zulu formatted DateTime, but got '%s'.", it.val)
        }
        return t, p.typeOfPrimitive(it)

Is this change in the works or does this need to be started on? I'd be glad to help get this worked in. The encode.go appears to need a change as well to have encoding be able to use UTC or non-UTC based time.

func (enc *Encoder) eElement(rv reflect.Value) {
    switch v := rv.Interface().(type) {
    case time.Time:
        // Special case time.Time as a primitive. Has to come before
        // TextMarshaler below because time.Time implements
        // encoding.TextMarshaler, but we need to always use UTC.
        enc.wf(v.In(time.FixedZone("UTC", 0)).Format("2006-01-02T15:04:05Z"))
        return

If you have any recommendations on this, I may have time to work a bit on this later this weekend. This lack of support blocks movement forward on another project that relies on this library.

@cespare cespare changed the title Update to TOML v0.4.0 Support all three kinds of TOML dates Feb 23, 2016
@cespare
Copy link
Collaborator

cespare commented Feb 23, 2016

Since the issue description is about TOML 0.4.0 dates specifically, I have changed the issue title. (I'll make a meta-issue or milestone for 0.4.0 later, and take stock of all the missing features.)

@cespare cespare changed the title Support all three kinds of TOML dates Decoder: support all three kinds of TOML dates Feb 23, 2016
@cespare cespare added this to the 0.4.0 milestone Feb 23, 2016
cespare added a commit that referenced this issue Apr 26, 2016
cespare added a commit that referenced this issue Apr 26, 2016
mitszo pushed a commit to accense/toml that referenced this issue Jul 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants