Method: DateTime.xmlschema

Defined in:
ext/date/date_core.c

.xmlschema(string = '-4712-01-01T00:00:00+00:00'[, start=Date::ITALY]) ⇒ Object

Creates a new DateTime object by parsing from a string according to some typical XML Schema formats.

DateTime.xmlschema('2001-02-03T04:05:06+07:00')

#=> #<DateTime: 2001-02-03T04:05:06+07:00 …>



8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
# File 'ext/date/date_core.c', line 8045

static VALUE
datetime_s_xmlschema(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("-4712-01-01T00:00:00+00:00");
      case 1:
  sg = INT2FIX(DEFAULT_SG);
    }

    {
  VALUE hash = date_s__xmlschema(klass, str);
  return dt_new_by_frags(klass, hash, sg);
    }
}