Date issues

Hi everyone. I know that the subject I chose is general, but it is a
mixture of problems.
I searched a lot in the group, in AWD with Rails book and some forums
and found a lot of threads but none of them solved my problem, many of
them didn't work at all.
The web site manager is going to set a start date for auction for
every goods, it is not necessarily the date that object is added to
database, but the manager has to set this date when he creates the
object in database. I want to have a simple date form field with year
month and day (for example 2010-05-09) but I don't know how to convert
it to date, the suggestions in the group didn't work ( i mean to_time
and to_date and etc)
Every auction is available for just one week. If i convert the string
to date i can easily add one week to the date. During the week for
every goods, clients can input their desired prices.But the new
problems arise, how can I find today's date is equal to the end date?
does it need a daily schedule for one week? It seems schedules are
complicated in Rails. Also when the maximum price for an object has
been chosen, do i have to delete the prices of ended auctions in order
to prevent the database getting bigger and bigger? or it is not
important?
Thanks a million and Excuse me for my long scenario.

Every auction is available for just one week. If i convert the string
to date i can easily add one week to the date. During the week for
every goods, clients can input their desired prices.But the new
problems arise, how can I find today's date is equal to the end date?

Equal, or just not there yet? :slight_smile:

endtime = Date.new(2010,7,4)

=> Sun, 04 Jul 2010

endtime.future?

=> true

now = DateTime.now.to_date

=> Thu, 01 Jul 2010

now.future?

=> false

(see the doc for ActiveSupport::CoreExtensions::date::Calculations)

.. do i have to delete the prices of ended auctions in order
to prevent the database getting bigger and bigger? or it is not
important?

How much is "bigger"? If you can afford the disk space, why worry?

Hi everyone. I know that the subject I chose is general, but it is a
mixture of problems.
I searched a lot in the group, in AWD with Rails book and some forums
and found a lot of threads but none of them solved my problem, many of
them didn't work at all.
The web site manager is going to set a start date for auction for
every goods, it is not necessarily the date that object is added to
database, but the manager has to set this date when he creates the
object in database. I want to have a simple date form field with year
month and day (for example 2010-05-09) but I don't know how to convert
it to date, the suggestions in the group didn't work ( i mean to_time
and to_date and etc)

Rather than storing a string I would suggest storing a datetime value
and just ignoring the time part(or make sure it is always 00:00).
Then it is immediately comparable with other dates by simple
comparison.

If you really need to convert the string then separate out the year,
month, day and use Time.utc, passing it the values, to create the time
object.

Colin