lua-users home
lua-l archive

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


Hi,

Richard Warburton wrote:
> function get_days_in_month(mnth, yr)
>  return os.date('*t',os.time{year=yr,month=mnth+1,day=0})['day']
> end
> 
> It returns 29 for February in 1900 and 2100, which are not leap years. 
> It appears to fail the rule: that years divisible by 100 (except those 
> divisible by 400) are not leap years.
> All other dates seem fine.
> 
> Is this a bug or am I missing something?

os.time() returns a time_t cast to a number. And time_t is very
likely a 32 bit type on your machine. It counts in seconds, so it
has a limited range, usually from 1970-2038 (signed 32 bit int).

I.e. you've found a (well known) limitation in your C library.

Bye,
     Mike