Editing Module:Date
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 907: | Line 907: | ||
-- Return filled date1, date2 (two full dates). | -- Return filled date1, date2 (two full dates). | ||
local function filled(a, b) | local function filled(a, b) | ||
local fillmonth, fillday | local fillmonth, fillday | ||
if not a.month then | if not a.month then | ||
Line 917: | Line 915: | ||
end | end | ||
if fillmonth or fillday then -- need to create a new date | if fillmonth or fillday then -- need to create a new date | ||
if (fillmonth or a.month) == 2 and (fillday or a.day) == 29 then | |||
-- Avoid invalid date, for example with {{age|2013|29 Feb 2016}} or {{age|Feb 2013|29 Jan 2015}}. | |||
if not is_leap_year(a.year, a.calendar) then | |||
}) | fillday = 28 | ||
end | |||
end | |||
a = Date(a, { month = fillmonth, day = fillday }) | |||
end | end | ||
return a | return a | ||
Line 1,401: | Line 1,402: | ||
end | end | ||
local H, M, S = diff.hours, diff.minutes, diff.seconds | local H, M, S = diff.hours, diff.minutes, diff.seconds | ||
if code == 'dh' or code == 'dhm' or code == 'dhms' or code == 'h' or code == 'hm' or code == 'hms | if code == 'dh' or code == 'dhm' or code == 'dhms' or code == 'h' or code == 'hm' or code == 'hms' then | ||
local days = floor(diff.age_days + extra_days) | local days = floor(diff.age_days + extra_days) | ||
local inc_hour | local inc_hour | ||
Line 1,416: | Line 1,417: | ||
inc_hour = true | inc_hour = true | ||
end | end | ||
end | end | ||
else | else | ||
Line 1,446: | Line 1,443: | ||
elseif code == 'hm' then | elseif code == 'hm' then | ||
return hours, M | return hours, M | ||
end | end | ||
return hours, M, S | return hours, M, S |