Method: Date.httpdate

Defined in:
ext/date/date_core.c

.httpdate(string = 'Mon, 01 Jan -4712 00:00:00 GMT'[, start=Date::ITALY]) ⇒ Object

Creates a new Date object by parsing from a string according to some RFC 2616 format.

Date.httpdate('Sat, 03 Feb 2001 00:00:00 GMT')

#=> #<Date: 2001-02-03 …>



4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
# File 'ext/date/date_core.c', line 4601

static VALUE
date_s_httpdate(int argc, VALUE *argv, VALUE klass)
{
    VALUE str, sg;

    rb_scan_args(argc, argv, "02", &str, &sg);

    switch (argc) {
      case 0:
  str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT");
      case 1:
  sg = INT2FIX(DEFAULT_SG);
    }

    {
  VALUE hash = date_s__httpdate(klass, str);
  return d_new_by_frags(klass, hash, sg);
    }
}