lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi.
I want to calculate days between two dates.
There isn't object date in Lua and I decided to write
function with string parameters to calculate this. Can
you somebody help me?
I wrote this:
function days( date1, date2 )
d1 = os.date("*t");
d1.hour, d1.min, d1.sec = 0, 0, 0;
d1.day, d1.month, d1.year = string.gfind( date1,
"(%d+).(%d+).(%d+)");
d2 = os.date("*t");
d2.hour, d2.min, d2.sec = 0, 0, 0;
d2.day, d2.month, d2.year = string.gfind( date2,
"(%d+).(%d+).(%d+)");
t1 = os.time( d1 );
t2 = os.time( d2 );
t = os.difftime( t1, t2 );
return ( t / (60*60*24) );
end

...but gfind do not work for me:-(
I need Lua-function like sscanf in C...
Thank You in advance.
Stoil

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/