method
parse
ruby latest stable - Class:
DateTime
parse(p1 = v1, p2 = v2, p3 = v3)public
Parses the given representation of date and time, and creates a DateTime object. This method does not function as a validator.
If the optional second argument is true and the detected year is in the range "00" to "99", makes it full.
DateTime .parse ('2001年02月03日T04:05:06+07:00') #=> #<DateTime: 2001年02月03日T04:05:06+07:00 ...> DateTime .parse ('20010203T040506+0700') #=> #<DateTime: 2001年02月03日T04:05:06+07:00 ...> DateTime .parse ('3rd Feb 2001 04:05:06 PM') #=> #<DateTime: 2001年02月03日T16:05:06+00:00 ...>
static VALUE
datetime_s_parse(int argc, VALUE *argv, VALUE klass)
{
VALUE str, comp, sg;
rb_scan_args(argc, argv, "03", &str, &comp, &sg);
switch (argc) {
case 0:
str = rb_str_new2("-4712年01月01日T00:00:00+00:00");
case 1:
comp = Qtrue;
case 2:
sg = INT2FIX(DEFAULT_SG);
}
{
VALUE argv2[2], hash;
argv2[0] = str;
argv2[1] = comp;
hash = date_s__parse(2, argv2, klass);
return dt_new_by_frags(klass, hash, sg);
}
}