FAQ
Hi all,

Trying to learn about time parsing.
Played with some simple examples, but I just can't figure out how to parse
this one: "2012-12-05 23:00:34 +0200". The error I get is "parsing time
"2012-12-05 23:00:34 +0200": month out of range".
Sample here code here: http://play.golang.org/p/tvPekI8AVS

Any ideas, pointers, etc. greatly appreciated. Nor 12 neither 05 seem like
out of range for a month (unless months are counted from 0?).

Thank you,

Cheers!
Alex Ungur

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Luzon83 at Dec 18, 2013 at 1:51 pm

    On Tuesday, December 17, 2013 7:22:44 PM UTC+1, Alexandru Ungur wrote:
    Hi all,

    Trying to learn about time parsing.
    Played with some simple examples, but I just can't figure out how to parse
    this one: "2012-12-05 23:00:34 +0200". The error I get is "parsing time
    "2012-12-05 23:00:34 +0200": month out of range".
    Sample here code here: http://play.golang.org/p/tvPekI8AVS

    Any ideas, pointers, etc. greatly appreciated. Nor 12 neither 05 seem like
    out of range for a month (unless months are counted from 0?).

    The layout must be the reference date/time:
    http://play.golang.org/p/7J_Eii3RDI

    See http://golang.org/pkg/time/#pkg-constants

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Kevin Gillette at Dec 19, 2013 at 11:19 pm
    This really could use a better error message, though it's unclear how to
    achieve that while still meeting Go 1 compatibility guarantees. Given
    http://play.golang.org/p/5nALeDw-IJ (2007 in the format string instead of
    2006), it seems the format is parsed as `<1 digit day><3 digit offset><2
    digit month><2 digit day>...` -- both the day and offset are recognized
    twice, while the year isn't recognized at all. While technically
    legitimate, intentional uses of a format like this would be exceedingly
    rare; we could check this in go vet, if not done already, but few of the
    people who've run into this issue know about or use vet.

    If error messages are not covered by the Go 1 guarantee, then if a date
    string parse error occurs, and the format string contains duplicate or
    undelimited, odd sequences of fields, then the error message could be
    expanded to indicate that the format date must correspond to the reference
    time.
    On Wednesday, December 18, 2013 6:51:29 AM UTC-7, luz...@gmail.com wrote:


    On Tuesday, December 17, 2013 7:22:44 PM UTC+1, Alexandru Ungur wrote:

    Hi all,

    Trying to learn about time parsing.
    Played with some simple examples, but I just can't figure out how to
    parse this one: "2012-12-05 23:00:34 +0200". The error I get is "parsing
    time "2012-12-05 23:00:34 +0200": month out of range".
    Sample here code here: http://play.golang.org/p/tvPekI8AVS

    Any ideas, pointers, etc. greatly appreciated. Nor 12 neither 05 seem
    like out of range for a month (unless months are counted from 0?).

    The layout must be the reference date/time:
    http://play.golang.org/p/7J_Eii3RDI

    See http://golang.org/pkg/time/#pkg-constants
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Chris dollin at Dec 18, 2013 at 1:54 pm
    On 17 December 2013 18:22, Alexandru Ungur wrote:

    Hi all,
    Trying to learn about time parsing.
    Played with some simple examples, but I just can't figure out how to parse
    this one: "2012-12-05 23:00:34 +0200". The error I get is "parsing time
    "2012-12-05 23:00:34 +0200": month out of range".
    Sample here code here: http://play.golang.org/p/tvPekI8AVS

    Any ideas, pointers, etc. greatly appreciated. Nor 12 neither 05 seem like
    out of range for a month (unless months are counted from 0?).
    The first argument to time.Parse mist be your chosen format's representation
    of the reference time (Mon Jan _2 15:04:05 2006). It certainly doesn't look
    like
    that's true, so I suspect that whatever this does to Parse's understanding
    of
    the comversion makes the result illegal.

    Chris


    --
    Chris "allusive" Dollin

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Alexandru Ungur at Dec 19, 2013 at 9:41 pm
    Thank you very much and sorry for the noise, I figured that out shortly
    after posting :( by reading the time package help slower this time...

    Have a great day!
    Alex Ungur

    marți, 17 decembrie 2013, 20:22:44 UTC+2, Alexandru Ungur a scris:
    Hi all,

    Trying to learn about time parsing.
    Played with some simple examples, but I just can't figure out how to parse
    this one: "2012-12-05 23:00:34 +0200". The error I get is "parsing time
    "2012-12-05 23:00:34 +0200": month out of range".
    Sample here code here: http://play.golang.org/p/tvPekI8AVS

    Any ideas, pointers, etc. greatly appreciated. Nor 12 neither 05 seem like
    out of range for a month (unless months are counted from 0?).

    Thank you,

    Cheers!
    Alex Ungur
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 18, '13 at 1:27p
activeDec 19, '13 at 11:19p
posts5
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase