红宝石 |时间星期天?()函数
sunday?()是 Ruby 中的一个内置方法,如果时间表示星期日,则返回 true,否则返回 false。
Syntax: time.sunday?()
Parameters: The function accepts no parameter
Return Value: It returns true if time represents sunday otherwise false.
示例 1 :
# Ruby code for sunday?() method
# Include Time
require 'time'
# Declaring time
a = Time.new(2000, 12, 23)
# Prints boolean value
puts a.sunday?()
输出:
false
示例 2 :
# Ruby code for sunday?() method
# Include Time
require 'time'
# Declaring time
a = Time.now()
# Prints boolean value
puts a.sunday?()
输出:
false