From ae3122e277f3a31db5db514db9aa90bac9e00e12 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Wed, 5 Oct 2011 22:31:05 -0400 Subject: [PATCH 3/4] Restore useful documentation for time.rb Moving the require to the top of the file and removing some extra documentation allows useful documentation to be shown. Also added some simple examples and removed now out-of-date minutia about strftime. --- lib/time.rb | 57 ++++++++++++++------------------------------------------- 1 files changed, 14 insertions(+), 43 deletions(-) diff --git a/lib/time.rb b/lib/time.rb index 6b1e9e5..37a90d0 100644 --- a/lib/time.rb +++ b/lib/time.rb @@ -1,51 +1,22 @@ +require 'date' # -# == Introduction -# -# This library extends the Time class: -# * conversion between date string and time object. -# * date-time defined by RFC 2822 -# * HTTP-date defined by RFC 2616 -# * dateTime defined by XML Schema Part 2: Datatypes (ISO 8601) -# * various formats handled by Date._parse (string to time only) -# -# == Design Issues -# -# === Specialized interface -# -# This library provides methods dedicated to special purposes: -# * RFC 2822, RFC 2616 and XML Schema. -# * They makes usual life easier. -# -# === Doesn't depend on strftime -# -# This library doesn't use +Time#strftime+. Especially #rfc2822 doesn't depend -# on +strftime+ because: -# -# * %a and %b are locale sensitive +# This library extends the Time class to provide common conversions between +# date strings and time objects: +# * date-time as defined by {RFC 2822}[http://www.ietf.org/rfc/rfc2822.txt] +# * HTTP-date as defined by {RFC 2616}[http://www.ietf.org/rfc/rfc2616.txt] +# * date\Time as defined by XML Schema Part 2: Datatypes ({ISO 8601}[http://www.iso.org/iso/date_and_time_format]) +# * various formats handled by Date._parse (string to time only) # -# Since they are locale sensitive, they may be replaced to -# invalid weekday/month name in some locales. -# Since ruby-1.6 doesn't invoke setlocale by default, -# the problem doesn't arise until some external library invokes setlocale. -# Ruby/GTK is the example of such library. -# -# * %z is not portable -# -# %z is required to generate zone in date-time of RFC 2822 -# but it is not portable. -# -# Note that +Time#strftime+ doesn't use +strftime()+ function in libc since Ruby 1.9. -# This means +Time#strftime+ is locale-insensitive since Ruby 1.9. -# The above statements are not valid now. +# == Examples # +# require 'time' +# +# t = Time.now +# t.iso8601 # => "2011-10-05T22:26:12-04:00" +# t.rfc2822 # => "Wed, 05 Oct 2011 22:26:12 -0400" +# t.httpdate # => "Thu, 06 Oct 2011 02:26:12 GMT" -require 'date' - -# -# Implements the extensions to the Time class that are described in the -# documentation for the time.rb library. -# class Time class << Time -- 1.7.7