Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Time#dst?

time.dst? → true or false

Alias of #isdst

Returns true if time occurs during Daylight Saving Time in its time zone.

Example
# 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
See also #isdst #day #eql? #ctime also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0