Module:Date: Difference between revisions

    (update from sandbox: a date difference accepts an option to fill missing fields to handle partial dates)
    (fix bug that can occur in {{age}} if attempt to make an invalid yyyy-02-29 date if need to fill month/day from other date)
    Line 915: 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 })
    a = Date(a, { month = fillmonth, day = fillday })
    end
    end