End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Time#wday
time.wday → integer
time.c
View on GitHub ↗
static VALUE
time_wday(VALUE time)
{
struct time_object *tobj;
GetTimeval(time, tobj);
MAKE_TM_ENSURE(time, tobj, tobj->vtm.wday != VTM_WDAY_INITVAL);
return INT2FIX((int)tobj->vtm.wday);
}
Returns an integer representing the day of the week, 0..6, with Sunday == 0.
Example
t = Time.now #=> 2007-11-20 02:35:35 -0600 t.wday #=> 2 t.sunday? #=> false t.monday? #=> false t.tuesday? #=> true t.wednesday? #=> false t.thursday? #=> false t.friday? #=> false t.saturday? #=> false