On 7/19/06, Shuying Wang <shuying / gmail.com> wrote:
> On 7/19/06, Harold Hausman <hhausman / gmail.com> wrote:
> > irb(main):004:0> Time.parse "Wed Jul 19 19:47:57 Malay Peninsula
> > Standard Time 2012"
> > => Wed Jul 19 19:47:57 Malay Peninsula Standard Time 2006
>
> irb(main):006:0> Time.parse("Wed Jul 19 19:47:57 Homer Simpson 2007")
> => Wed Jul 19 19:47:57 SGT 2006
> irb(main):018:0> Time.parse("Wed Jul 19 19:47:57 SGT 2007")
> => Thu Jul 19 19:47:57 SGT 2007
>
> So it's to do with the fact that you've got spaces in your timezone.

Not exactly - it's even more picky than that.  It looks like with
strings of the format
"Wed Jul 19 19:47:57 ANYTHING 2007", that anything is ignored unless
it is 'GMT' and the current TZ is used, but the year is accepted.  But
if you have more than one string between the time and the year, then
everything is ignored and it uses the current year.

irb(main):099:0> Time.parse "Thu Jul 19 18:21:38"
=> Wed Jul 19 18:21:38 Pacific Standard Time 2006
irb(main):100:0> Time.parse "Wed Jul 19 18:21:38 PST 2007"
=> Thu Jul 19 19:21:38 Pacific Standard Time 2007
irb(main):101:0> Time.parse "Wed Jul 19 18:21:38 SGT 2007"
=> Thu Jul 19 18:21:38 Pacific Standard Time 2007
irb(main):102:0> Time.parse "Wed Jul 19 18:21:38 GMT 2007"
=> Thu Jul 19 18:21:38 UTC 2007
irb(main):103:0> Time.parse "Wed Jul 19 18:21:38 GMT anything 2007"
=> Wed Jul 19 18:21:38 UTC 2006
irb(main):104:0> Time.parse "Wed Jul 19 18:21:38 PST anything 2007"
=> Wed Jul 19 19:21:38 Pacific Standard Time 2006


What's interesting is that the docs for parse suggest that a lot more
timezone names should be accepted:
http://www.ruby-doc.org/core/classes/Time.html#M000264 says
"..., this method only understands the timezone abbreviations
described in RFC 822 and the system timezone, in the order named...."

but it doesn't even handle 'GMT+n'

irb(main):105:0> Time.parse "Wed Jul 19 18:21:38 GMT 2007"
=> Thu Jul 19 18:21:38 UTC 2007
irb(main):106:0> Time.parse "Wed Jul 19 18:21:38 GMT+4 2007"
=> Wed Jul 19 18:21:38 UTC 2006

-Adam