Строка 1: |
Строка 1: |
| -- Date functions for use by other modules. | | -- Date functions for use by other modules. |
| -- I18N and time zones are not supported. | | -- I18N and time zones are not supported. |
− | -- Original source: [[:en:Module:Date]]
| |
| | | |
| local MINUS = '−' -- Unicode U+2212 MINUS SIGN | | local MINUS = '−' -- Unicode U+2212 MINUS SIGN |
Строка 908: |
Строка 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 |
Строка 916: |
Строка 917: |
| 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, { month = fillmonth, day = fillday }) | + | a = Date(a, { |
| + | month = fillmonth, |
| + | day = math.min(fillday or a.day, days_in_month(a.year, fillmonth or a.month, a.calendar)) |
| + | }) |
| end | | end |
| return a | | return a |
Строка 1397: |
Строка 1401: |
| 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' then | + | 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 |
| local days = floor(diff.age_days + extra_days) | | local days = floor(diff.age_days + extra_days) |
| local inc_hour | | local inc_hour |
Строка 1412: |
Строка 1416: |
| inc_hour = true | | inc_hour = true |
| end | | end |
| + | end |
| + | elseif code == 'M' then |
| + | if S >= 30 then |
| + | M = M + 1 |
| end | | end |
| else | | else |
Строка 1438: |
Строка 1446: |
| 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 |