About time compare

I have a submmited date param whose data type is date and want to use
the Time object and the date param to judge if the date param passes the
today. I use the following codes judging:
#########
date.yday-Time.now.yday<0
##########
But i do not know if this code is right.Anyone tell me?

On Aug 22, 5:22 am, Guo Y. [email protected]
wrote:

I have a submmited date param whose data type is date and want to use
the Time object and the date param to judge if the date param passes the
today. I use the following codes judging:
#########
date.yday-Time.now.yday<0
##########

why not just date < Time.now ?

Fred

why not just date < Time.now ?

Fred

I just want to compare the year,month,and day,but Time.now includes the
miniute

On 22 Aug 2008, at 09:35, Guo Y. wrote:

why not just date < Time.now ?

Fred

I just want to compare the year,month,and day,but Time.now includes
the
miniute

You could use the to_date method to compare the actual dates (or use
change(:hour =>0) which discard the hour minute and seconds components)

Fred

You could use the to_date method to compare the actual dates (or use
change(:hour =>0) which discard the hour minute and seconds components)

Fred

Thank you very much!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs