From: Glen Holcomb Date: 2009-10-07T03:42:40+09:00 Subject: Re: Ruby for the wrong reason --0015175cd87e1bd42a04754898b0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On Tue, Oct 6, 2009 at 12:33 PM, 7stud -- wrote: > James Edward Gray II wrote: > > On Oct 6, 2009, at 1:16 AM, 7stud -- wrote: > > > >> No. I think in ruby the code would be almost exactly the same--except > >> it's significantly harder to figure out in ruby because there is no > >> documentation about the format specifiers you can use with strftime() > >> and strptime(). Amazing, huh? > > > > Amazingly wrong, yeah: > > > > Not at all: > > 1) $ri Date::strptime > > --------------------------------------------------------- Date::strptime > Date::strptime(str=3D'-4712-01-01', fmt=3D'%F', sg=3DITALY) > ------------------------------------------------------------------------ > Create a new Date object by parsing from a String according to a > specified format. > > +str+ is a String holding a date representation. +fmt+ is the > format that the date is in. See date/format.rb for details on > supported formats. > > The default +str+ is '-4712-01-01', and the default +fmt+ is '%F', > which means Year-Month-Day_of_Month. This gives Julian Day Number > day 0. > > +sg+ specifies the Day of Calendar Reform. > > An ArgumentError will be raised if +str+ cannot be parsed. > ----------------------------- > > Good luck finding and then digging through the **source code** of > format.rb to locate anything on the format specifiers. > > > 2) $ri Date#strftime > > ---------------------------------------------------------- Date#strftime > strftime(fmt=3D'%F') > ------------------------------------------------------------------------ > (no description...) > > > > And from the official Standard Library Documentation for 'date': > > 1) > strptime(str=3D'-4712-01-01', fmt=3D'%F', sg=3DITALY) > ---------------------------------------- > > Create a new Date object by parsing from a String according to a > specified format. > > str is a String holding a date representation. fmt is the format that > the date is in. See date/format.rb for details on supported formats. > > The default str is =92-4712-01-01=92, and the default fmt is =92%F=92, wh= ich > means Year-Month-Day_of_Month. This gives Julian Day Number day 0. > > sg specifies the Day of Calendar Reform. > > An ArgumentError will be raised if str cannot be parsed. > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > 2) > strftime(fmt=3D'%F') > -------------- > [Source] > > That last one is a real doozy--and quite typical of ruby Standard > Library documentation. > > -- > Posted via http://www.ruby-forum.com/. > > With the above approach one might benefit by starting with: ri strftime Then looking at "all" the strftime methods. --=20 "Hey brother Christian with your high and mighty errand, Your actions speak so loud, I can=92t hear a word you=92re saying." -Greg Graffin (Bad Religion) --0015175cd87e1bd42a04754898b0--