Method: DateTime#strftime
- Defined in:
- ext/date_ext/datetime.c
#strftime ⇒ String <br /> #strftime(format) ⇒ String
If no argument is provided, returns a string in ISO8601 format, just like to_s. If an argument is provided, uses it as a format string and returns a String based on the format. See Date#strftime for the supported formats.
1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 |
# File 'ext/date_ext/datetime.c', line 1606
static VALUE rhrdt_strftime(int argc, VALUE *argv, VALUE self) {
rhrdt_t* dt;
VALUE r;
switch(argc) {
case 0:
return rhrdt_to_s(self);
case 1:
r = rb_str_to_str(argv[0]);
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments: %i for 1", argc);
break;
}
Data_Get_Struct(self, rhrdt_t, dt);
RHRDT_FILL_CIVIL(dt)
RHRDT_FILL_JD(dt)
RHRDT_FILL_HMS(dt)
RHRDT_FILL_NANOS(dt)
return rhrd__strftime(dt, RSTRING_PTR(r), RSTRING_LEN(r));
}
|