diff options
Diffstat (limited to 'macros/luatex/generic/lualibs/lualibs-os.lua')
-rw-r--r-- | macros/luatex/generic/lualibs/lualibs-os.lua | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/macros/luatex/generic/lualibs/lualibs-os.lua b/macros/luatex/generic/lualibs/lualibs-os.lua index 9aa8b8aa78..1e01350947 100644 --- a/macros/luatex/generic/lualibs/lualibs-os.lua +++ b/macros/luatex/generic/lualibs/lualibs-os.lua @@ -604,11 +604,19 @@ os.isleapyear = isleapyear local days = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -local function nofdays(year,month) +local function nofdays(year,month,day) if not month then return isleapyear(year) and 365 or 364 - else + elseif not day then return month == 2 and isleapyear(year) and 29 or days[month] + else + for i=1,month-1 do + day = day + days[i] + end + if month > 2 and isleapyear(year) then + day = day + 1 + end + return day end end |