In Files

  • rss/rss.rb

Parent

Methods

Class/Module Index [+]

Quicksearch

Time

Public Class Methods

w3cdtf(date) click to toggle source
 
               # File rss/rss.rb, line 6
def w3cdtf(date)
  if /\A\s*
      (-?\d+)-(\d\d)-(\d\d)
      (?:T
      (\d\d):(\d\d)(?::(\d\d))?
      (\.\d+)?
      (Z|[+-]\d\d:\d\d)?)?
      \s*\z/x =~ date and (($5 and $8) or (!$5 and !$8))
    datetime = [$1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i]
    usec = 0
    usec = $7.to_f * 1000000 if $7
    zone = $8
    if zone
      off = zone_offset(zone, datetime[0])
      datetime = apply_offset(*(datetime + [off]))
      datetime << usec
      time = Time.utc(*datetime)
      time.localtime unless zone_utc?(zone)
      time
    else
      datetime << usec
      Time.local(*datetime)
    end
  else
    raise ArgumentError.new("invalid date: #{date.inspect}")
  end
end
            

Public Instance Methods

w3cdtf() click to toggle source
 
               # File rss/rss.rb, line 37
def w3cdtf
  if usec.zero?
    fraction_digits = 0
  else
    fraction_digits = Math.log10(usec.to_s.sub(/0*$/, '').to_i).floor + 1
  end
  xmlschema(fraction_digits)
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.

blog comments powered by Disqus