From: Sam Roberts Date: 2006-05-04T06:08:27+09:00 Subject: Re: parsedate doesn't work on Time.now.to_s On Thu, May 04, 2006 at 04:37:56AM +0900, Austin Ziegler wrote: > On 5/3/06, Berger, Daniel wrote: > >Take a look at time_to_s in time.c and you'll see this line: > > > >len = strftime(buf, 128, "%a %b %d %H:%M:%S %Z %Y", &tobj->tm); > > > >The 'issue' is %Z. Reading the man page on Solaris is merely says "time > >zone name or abbreviation". How it determines which to use, I'm not > >sure. On Windows it's apparently controlled by a registry setting > >somewhere (Windows also supports %z). So, my guess is most *nix systems > >default to the abbreviation, while Windows defaults to the long name. > > > >I don't think we need to fix time_to_s, however. We need to fix > >ParseDate. > > >>Time.now.strftime("%a %b %d %H:%M:%S %z %Y") > => "Wed May 03 15:37:18 Eastern Daylight Time 2006" > > Note the use of "%z" as opposed to "%Z". Windows is hosed. The 1.8.4 source doesn't document %z as an allowed conversion. The linux man page describes it as a GNU extension: %z The time-zone as hour offset from GMT. Required to emit RFC822-conformant dates (using "%a, %d %b %Y %H:%M:%S %z"). (GNU) So while I think Windows is hosed as a general principle, I think its within its rights in this case. The ruby code isn't validating the string input, just passing it to the strftime(), if ruby is supposed to support %z portably, it will have to do it itself. Its kindof useful to be able to use the local extensions, of course: ruby -e 'p Time.now.strftime("%P %r")' "pm 01:59:33 PM" even if not very portable. Kind of a pain to have to reimplement library functions, but when they give access to non-standard behaviour, what is the right approach? Cheers, Sam