Module:Age: Difference between revisions
fix bug that can occur in {{age in years, months, weeks and days}} if attempt to make an invalid yyyy-02-29 date due to unwise wantMixture used to emulate original template
(update from sandbox: use data-sort-value for sort keys per Module talk:Age#Sorting will use data-sort-value) |
(fix bug that can occur in {{age in years, months, weeks and days}} if attempt to make an invalid yyyy-02-29 date due to unwise wantMixture used to emulate original template) |
||
Line 624: | Line 624: | ||
for i = 1, nrDates do | for i = 1, nrDates do | ||
local index = i == 1 and 1 or 4 | local index = i == 1 and 1 or 4 | ||
local y, m, d = fields[index], fields[index+1], fields[index+2] | |||
if (m == 2 or m == '2') and (d == 29 or d == '29') then | |||
-- Workaround error with following which attempt to use invalid date 2001-02-29. | |||
-- {{age_ymwd|year1=2001|year2=2004|month2=2|day2=29}} | |||
-- {{age_ymwd|year1=2001|month1=2|year2=2004|month2=1|day2=29}} | |||
-- TODO Get rid of wantMixture because even this ugly code does not handle | |||
-- 'Feb' or 'February' or 'feb' or 'february'. | |||
if not ((y % 4 == 0 and y % 100 ~= 0) or y % 400 == 0) then | |||
d = 28 | |||
end | |||
end | |||
dates[i] = Date(y, m, d) | |||
end | end | ||
else | else |