0

我正在尝试像这样进行日期比较:

if date > "Sept 22"
#do stuff
else
#do other stuff
end

我只是想不出如何在 Ruby 中做到这一点(至少看一个特定的日期)。

4

1 回答 1

6

Normal comparison operators work with dates too:

require 'date'

date = Date.new(2012,3,3)

if date > Date.new(2011,4,4)
  # do whatever
end
于 2012-09-19T17:49:04.487 回答