Editing Module:Date

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. Read the Privacy Policy to learn what information we collect about you and how we use it.

If you log in or create an account, your edits will be attributed to your username, along with other benefits.

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)
-- Return date a filled, if necessary, with month and/or day from date b.
-- The filled day is truncated to fit the number of days in the month.
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
a = Date(a, {
if (fillmonth or a.month) == 2 and (fillday or a.day) == 29 then
month = fillmonth,
-- Avoid invalid date, for example with {{age|2013|29 Feb 2016}} or {{age|Feb 2013|29 Jan 2015}}.
day = math.min(fillday or a.day, days_in_month(a.year, fillmonth or a.month, a.calendar))
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' or code == 'M' or code == 's' then
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
elseif code == 'M' then
if S >= 30 then
M = M + 1
end
end
else
else
Line 1,446: Line 1,443:
elseif code == 'hm' then
elseif code == 'hm' then
return hours, M
return hours, M
elseif code == 'M' or code == 's' then
M = hours * 60 + M
if code == 'M' then
return M
end
return M * 60 + S
end
end
return hours, M, S
return hours, M, S
Please note that all contributions to Nonbinary Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see Nonbinary Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Template used on this page: