Project

General

Profile

Bug #8821 ยป 0001-Add-documentation-for-the-w3cdtf-methods-on-Time.patch

steveklabnik (Steve Klabnik), 08/27/2013 06:15 AM

View differences:

lib/rss/rss.rb
3 3
class Time
4 4
  class << self
5 5
    unless respond_to?(:w3cdtf)
6
      # The w3cdtf method converts a String in W3CDTF date/time format to Time
7
      # object.
8
      #
9
      # The W3CDTF format is defined here: http://www.w3.org/TR/NOTE-datetime
10
      #
11
      #   Time.w3cdtf('2003-02-15T13:50:05-05:00')
12
      #   # => 2003-02-15 10:50:05 -0800
13
      #   Time.w3cdtf('2003-02-15T13:50:05-05:00').class
14
      #   # => Time
6 15
      def w3cdtf(date)
7 16
        if /\A\s*
8 17
            (-?\d+)-(\d\d)-(\d\d)
......
34 43
  end
35 44

  
36 45
  unless method_defined?(:w3cdtf)
46
    # The w3cdtf method converts a Time object to a String. The String contains
47
    # the time in W3CDTF date/time format.
48
    #
49
    # The W3CDTF format is defined here: http://www.w3.org/TR/NOTE-datetime
50
    #
51
    #  Time.now.w3cdtf
52
    #  # => "2013-08-26T14:12:10.817124-07:00"
37 53
    def w3cdtf
38 54
      if usec.zero?
39 55
        fraction_digits = 0
40
-