[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: how to compare 2 dates
- From: Doug Rogers <doug.rogers@...>
- Date: Wed, 06 May 2009 13:49:12 -0400
Diego - Red Baires wrote:
myDate = "05/21/2009";
...
if ( os.date() < myDate) then
print "myDate is in the future";
is this correct ?
will this work to all locales ?
what about comparing times ? (i mean, if a time is between two values)
Diego, your best bet is to convert the date into a time. You'll need to
extract the month, day, and year, then pass that into os.time().
function date2time(s)
local m, d, y = s:match("(%d+)/(%d+)/(%d+)")
if not y then
return nil, "improper date format"
end
return os.time({ year = y, month = m, day = d })
end
t = assert(date2time("05/21/2009"))
Then you may compare these values.
Doug
______________________________________________________________________________________
The information contained in this email transmission may contain proprietary and business
sensitive information. If you are not the intended recipient, you are hereby notified that
any review, dissemination, distribution or duplication of this communication is strictly
prohibited. Unauthorized interception of this e-mail is a violation of law. If you are not
the intended recipient, please contact the sender by reply email and immediately destroy all
copies of the original message.
Any technical data and/or information provided with or in this email may be subject to U.S.
export controls law. Export, diversion or disclosure contrary to U.S. law is prohibited.
Such technical data or information is not to be exported from the U.S. or given to any foreign
person in the U.S. without prior written authorization of Elbit Systems of America and the
appropriate U.S. Government agency.