rfc2822(date)
  public
  
    
    
Parses date as date-time defined by RFC 2822 and converts it to a
Time object.  The format is identical to the date
format defined by RFC 822 and updated by RFC 1123.
ArgumentError is raised if date
is not compliant with RFC 2822 or if the Time
class cannot represent specified date.
See #rfc2822 for more information on this
format.
You must require ‘time’ to use this method.
   
  
    Show source    
    
      
    def rfc2822(date)
      if /\A\s*
          (?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s*,\s*)?
          (\d{1,2})\s+
          (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+
          (\d{2,})\s+
          (\d{2})\s*
          :\s*(\d{2})\s*
          (?::\s*(\d{2}))?\s+
          ([+-]\d{4}|
           UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[A-IK-Z])/x =~ date
        
        day = $1.to_i
        mon = MonthValue[$2.upcase]
        year = $3.to_i
        short_year_p = $3.length <= 3
        hour = $4.to_i
        min = $5.to_i
        sec = $6 ? $6.to_i : 0
        zone = $7
        if short_year_p
          
          year = if year < 50
                   2000 + year
                 else
                   1900 + year
                 end
        end
        off = zone_offset(zone)
        year, mon, day, hour, min, sec =
          apply_offset(year, mon, day, hour, min, sec, off)
        t = self.utc(year, mon, day, hour, min, sec)
        force_zone!(t, zone, off)
        t
      else
        raise ArgumentError.new("not RFC 2822 compliant date: #{date.inspect}")
      end
    end