"Adam Shelly" <adam.shelly / gmail.com> writes:

> 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.  

My local time is EDT (-4:00)
irb(main):018:0> Time.parse("Wed Jul 19 19:47:57 2007")
Thu Jul 19 19:47:57 EDT 2007
irb(main):019:0> Time.parse("Wed Jul 19 19:47:57 ANYTHING 2007")
Thu Jul 19 19:47:57 EDT 2007


To specify SGT time (+6:00):

irb(main):020:0> Time.parse("Wed Jul 19 19:47:57 +06:00 2007")
Thu Jul 19 09:47:57 EDT 2007
irb(main):021:0> Time.parse("Wed Jul 19 19:47:57 +0600 2007")
Thu Jul 19 09:47:57 EDT 2007



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

RFC822 does not specify GMT+n format.

"
   zone        =  "UT"  / "GMT"                ; Universal Time
                                                 ; North American : UT
                 /  "EST" / "EDT"                ;  Eastern:  - 5/ - 4
                 /  "CST" / "CDT"                ;  Central:  - 6/ - 5
                 /  "MST" / "MDT"                ;  Mountain: - 7/ - 6
                 /  "PST" / "PDT"                ;  Pacific:  - 8/ - 7
                 /  1ALPHA                       ; Military: Z = UT;
                                                 ;  A:-1; (J not used)
                                                 ;  M:-12; N:+1; Y:+12
                 / ( ("+" / "-") 4DIGIT )        ; Local differential
                                                 ;  hours+min. (HHMM)
"
It specifies +nnnn format.

In any case, Time.parse does not accept everything specified in
RFC822. It ignores UT and 1ALPHA (eg: 1Z for UTC and 1N for UTC+0100).


YS.