Method: Time#dst?
- Defined in:
- time.c
permalink #isdst ⇒ Boolean #dst? ⇒ Boolean
Returns true
if time occurs during Daylight Saving Time in its time zone.
# CST6CDT:
Time.local(2000, 1, 1).zone #=> "CST"
Time.local(2000, 1, 1).isdst #=> false
Time.local(2000, 1, 1).dst? #=> false
Time.local(2000, 7, 1).zone #=> "CDT"
Time.local(2000, 7, 1).isdst #=> true
Time.local(2000, 7, 1).dst? #=> true
# Asia/Tokyo:
Time.local(2000, 1, 1).zone #=> "JST"
Time.local(2000, 1, 1).isdst #=> false
Time.local(2000, 1, 1).dst? #=> false
Time.local(2000, 7, 1).zone #=> "JST"
Time.local(2000, 7, 1).isdst #=> false
Time.local(2000, 7, 1).dst? #=> false
4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 |
# File 'time.c', line 4738
static VALUE
time_isdst(VALUE time)
{
struct time_object *tobj;
GetTimeval(time, tobj);
MAKE_TM(time, tobj);
if (tobj->vtm.isdst == VTM_ISDST_INITVAL) {
rb_raise(rb_eRuntimeError, "isdst is not set yet");
}
return tobj->vtm.isdst ? Qtrue : Qfalse;
}
|