From: Austin Ziegler Date: 2004-08-05T00:19:43+09:00 Subject: Re: Time#zone On Wed, 4 Aug 2004 23:55:08 +0900, Farrel Lifson wrote: > Nope that don't work on XP: > irb(main):001:0> Time.now.strftime("%Z") > => "South Africa Standard Time" > I assume from this it seems that the Ruby interpreter gets the time > zone string (whether long or abbreviated) from the underlying OS? I'd > like to create a date string that is as close as possible to time > specification as set in RFC 822 > (http://www.freesoft.org/CIE/RFC/822/39.htm). It would be nice if the > default Time#to_s returned a 822 compliant string though... > > I guess I'm just going to have to go with either using the uct offset > or doing some processing. Without Ruby having this information inbuilt, there's no way that it can do this. IMO, Ruby shouldn't have this information inbuilt, it should get the information from the OS. However, you could try this: Time.now.zone.gsub(/([A-Z])\w+\b\s?/, '\1') Time.now.zone.split.map { |e| e[0].chr }.join("") There may be better ways to get the first letter of each word. (Unfortunately, this is also language and locale specific). Alternatively, you could include the ISO timezone definitions in your class and convert between the UTC offset and the timezone definitions -- but that's an iffy proposition (you can't tell regarding Indiana, which switches between EST and CST instead of going on EDT). -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca