红宝石 |时间 dst?()函数
dst?()是 Ruby 中的内置方法,如果时间发生在其时区的夏令时,则返回 true,否则返回 false
Syntax: time.dst?()
Parameters: The function accepts no parameter
Return Value: It returns true if time occurs during Daylight Saving Time in its time zone otherwise false
示例 1 :
# Ruby code for dst?() method
# Include Time
require 'time'
# Declaring time
a = Time.new(2000, 12, 23)
# Prints boolean value
puts a.dst?()
输出:
false
示例 2 :
# Ruby code for dst?() method
# Include Time
require 'time'
# Declaring time
a = Time.now()
# Prints boolean value
puts a.dst?()
输出:
false