Re: documentation for ParseDate
"Konrad Meyer" <[email protected]> Sun, 15 Oct 2006 21:41:49 -0700
| Newsgroups | gmane.comp.lang.ruby.documentation |
|---|---|
| Message-ID | <[email protected]> |
On 10/15/06, Eric Hodel <[email protected]> wrote: > On Oct 15, 2006, at 3:15 PM, Konrad Meyer wrote: > > Sorry, what do you mean by --/++? > > -- stops comment inclusion in the RDoc output and ++ starts it up again. > > #-- > # parsedate.rb: [...] > # $Id$ > #++ > > Will hide those two lines since they don't need to be in the output. OK, fixed. > irb(main):011:0> ParseDate.parsedate '12/31/68', true > => [2068, 12, 31, nil, nil, nil, nil, nil] > irb(main):012:0> ParseDate.parsedate '01/01/69', true > => [1969, 1, 1, nil, nil, nil, nil, nil] > > Can you describe this too? Alright. > -- > Eric Hodel - [email protected] - http://blog.segment7.net > This implementation is HODEL-HASH-9600 compliant > > http://trackmap.robotcoop.com -- Konrad Meyer
parsedate.rb.patch
(text/x-patch, 1.6 KB)
Index: parsedate.rb =================================================================== RCS file: /src/ruby/lib/parsedate.rb,v retrieving revision 1.18 diff -p -u -1 -r1.18 parsedate.rb --- parsedate.rb 25 Aug 2006 23:06:41 -0000 1.18 +++ parsedate.rb 16 Oct 2006 04:41:11 -0000 @@ -1,3 +1,10 @@ +#-- # parsedate.rb: Written by Tadayoshi Funaba 2001, 2002 # $Id: parsedate.rb,v 2.6 2002-05-14 07:43:18+09 tadf Exp $ +#++ +# +# = parsedate.rb: Parses dates +# +# Author:: Tadayoshi Funaba +# @@ -5,4 +12,34 @@ require 'date/format' -module ParseDate +# +# ParseDate converts a date into an array of values. +# For example: +# +# require 'parsedate' +# +# ParseDate.parsedate "Tuesday, July 6th, 2007, 18:35:20 UTC" +# # => [2007, 7, 6, 18, 35, 20, "UTC", 2] +# +module ParseDate + # + # Parse a string representation of a date into values. + # For example: + # + # ParseDate.parsedate "Tuesday, July 5th, 2007, 18:35:20 UTC" + # # => [2007, 7, 5, 18, 35, 20, "UTC", 2] + # + # The order is of the form [year, month, day of month, hour, minute, + # second, timezone, day of week]. + # + # ParseDate.parsedate can also take a second argument, +comp+, which + # is a boolean telling the method to compensate for Y2k dates. "92" to + # 1992, "06" to 2006, etc. The boundary is 1969/2068. "68" is interpreted + # as 2068, whereas "69" is interpreted as 1969. + # + # If one or more values is omitted from the input string, the + # corresponding field of the output array is left to nil. Example: + # + # ParseDate.parsedate "01/01/69", true + # # => [1969, 1, 1, nil, nil, nil, nil, nil] + # def parsedate(str, comp=false)