I have a date variable, stored as a String in the 'YYYY-mm-dd' format. What is the best way to check, if that date开发者_如何学Go has not already passed?
Date.parse('2010-11-01') < Date.today
will return true if '2010-11-01' has already passed
You can also use past?
Date.parse("2012-11-01").past?
If you want to compare some attributes of dates, you can do this too:
Date.parse('2010-11-01').month < Date.today.month
Date.parse('2010-11-01').year < Date.today.year
Date.parse('2010-11-01').day < Date.today.day
精彩评论