APIdock / Ruby
/
method

parse

ruby latest stable - Class: Date
parse(p1 = v1, p2 = v2, p3 = v3)
public

Parses the given representation of date and time, and creates a date 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", considers the year a 2-digit form and makes it full.

Date .parse ('2001年02月03日') #=> #<Date: 2001年02月03日 ...>
Date .parse ('20010203') #=> #<Date: 2001年02月03日 ...>
Date .parse ('3rd Feb 2001') #=> #<Date: 2001年02月03日 ...>
static VALUE
date_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日");
 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 d_new_by_frags(klass, hash, sg);
 }
}

AltStyle によって変換されたページ (->オリジナル) /