lua-users home
lua-l archive

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


>d1.day, d1.month, d1.year = string.gfind( date1, "(%d+).(%d+).(%d+)");
>...but gfind do not work for me:-(

You need to ignore the first 2 return values. Try the code below.
--lhf

function str2time(s)
 local d={}
 local a,b
 a, b, d.day, d.month, d.year = string.find(s, "(%d+).(%d+).(%d+)");
 return os.time(d)
end

function diff(a,b)
 return os.difftime(str2time(b),str2time(a))/(60*60*24)
end