Wikipedia
eewiki
https://ee.wikipedia.org/wiki/Axa_do_%C5%8Ag%C9%94
MediaWiki 1.46.0-wmf.22
first-letter
Media
Special
Talk
User
User talk
Wikipedia
Wikipedia talk
File
File talk
MediaWiki
MediaWiki talk
Template
Template talk
Help
Help talk
Category
Category talk
TimedText
TimedText talk
Module
Module talk
Event
Event talk
Module:Age utilities
828
11232
61369
2026-04-08T06:17:12Z
A.sav
6365
L10n of [[:no:Mal:Age utilities]]
61369
wikitext
text/x-wiki
local p = {}
--------------------------------------------------------------------------------
-- Local helper functions
--------------------------------------------------------------------------------
-- Returns true if year is/was a leap year
local function isLeapYear(year)
return year % 4 == 0 and (year % 100 ~= 0 or year % 400 == 0)
end
-- Copied from [[en:Module:Age]]
local function gsd(year, month, day)
-- Return the Gregorian serial day (an integer >= 1) for the given date,
-- or return nil if the date is invalid (only check that year >= 1).
-- This is the number of days from the start of 1 AD (there is no year 0).
-- This code implements the logic in [[Template:Gregorian serial date]].
if year < 1 then
return nil
end
local floor = math.floor
local days_this_year = (month - 1) * 30.5 + day
if month > 2 then
if isLeapYear(year) then
days_this_year = days_this_year - 1
else
days_this_year = days_this_year - 2
end
if month > 8 then
days_this_year = days_this_year + 0.9
end
end
days_this_year = floor(days_this_year + 0.5)
year = year - 1
local days_from_past_years = year * 365
+ floor(year / 4)
- floor(year / 100)
+ floor(year / 400)
return days_from_past_years + days_this_year
end
-- Returns the magnitude of a number defined as the integer part of log10 of the absolute value of the number
-- Equivalent to [[Mal:Magnitude]]
local function magnitude(number)
if number == 0 then return nil end
return math.floor(math.log10(math.abs(number)))
end
--------------------------------------------------------------------------------
-- Functions for calculating age
--------------------------------------------------------------------------------
-- Returns age in years and days. Input is two dates in numeric form as returned from os.time
function p.ageInYearsAndDays(date2N, date1N)
local date1 = os.date('!*t', date1N)
local date2 = os.date('!*t', date2N)
local age = {}
age.years = date2.year - date1.year;
if date2.month < date1.month or date2.month == date1.month and date2.day < date1.day then
age.years = age.years - 1
end
local year = date2.year
if date2.month < date1.month or date2.month == date1.month and date2.day < date1.day then
year = year - 1
end
age.days = gsd(date2.year, date2.month, date2.day) - gsd(year, date1.month, date1.day)
return age
end
--------------------------------------------------------------------------------
-- Functions for comparing ages
--------------------------------------------------------------------------------
-- Returns < 0 if ageA < ageB, 0 if ageA == ageB, > 0 if ageA > ageB
function p.compareAges(ageA, ageB)
if ageA.years ~= ageB.years then
if ageA.years < ageB.years then return -1 end
return 1
end
if ageA.days ~= ageB.days then
if ageA.days < ageB.days then return -1 end
return 1
end
return 0 -- equal
end
-- Returns true if ageA == ageB
function p.equalAges(ageA, ageB)
return p.compareAges(ageA, ageB) == 0
end
--------------------------------------------------------------------------------
-- Functions for displaying age
--------------------------------------------------------------------------------
-- Returns a date as a sortable string with age in years and days ("x aasta(t), y päev(a)")
function p.ageInYearsAndDaysFormat(age)
local result = tostring(age.years) .. ' ' .. (age.years == 1 and 'aasta' or 'aastat')
.. ', ' .. tostring(age.days) .. ' ' .. (age.days == 1 and 'päev' or 'päeva')
return '<span data-sort-value="' .. tostring(1000 * age.years + age.days) .. '">' .. result .. '</span>'
end
return p
i9uieh4qb7ubiene9nfo6on74k7dowz
61370
61369
2026-04-08T06:18:41Z
A.sav
6365
A.sav moved axa [[Modul:Age utilities]] yi [[Module:Age utilities]]: Misspelled title
61369
wikitext
text/x-wiki
local p = {}
--------------------------------------------------------------------------------
-- Local helper functions
--------------------------------------------------------------------------------
-- Returns true if year is/was a leap year
local function isLeapYear(year)
return year % 4 == 0 and (year % 100 ~= 0 or year % 400 == 0)
end
-- Copied from [[en:Module:Age]]
local function gsd(year, month, day)
-- Return the Gregorian serial day (an integer >= 1) for the given date,
-- or return nil if the date is invalid (only check that year >= 1).
-- This is the number of days from the start of 1 AD (there is no year 0).
-- This code implements the logic in [[Template:Gregorian serial date]].
if year < 1 then
return nil
end
local floor = math.floor
local days_this_year = (month - 1) * 30.5 + day
if month > 2 then
if isLeapYear(year) then
days_this_year = days_this_year - 1
else
days_this_year = days_this_year - 2
end
if month > 8 then
days_this_year = days_this_year + 0.9
end
end
days_this_year = floor(days_this_year + 0.5)
year = year - 1
local days_from_past_years = year * 365
+ floor(year / 4)
- floor(year / 100)
+ floor(year / 400)
return days_from_past_years + days_this_year
end
-- Returns the magnitude of a number defined as the integer part of log10 of the absolute value of the number
-- Equivalent to [[Mal:Magnitude]]
local function magnitude(number)
if number == 0 then return nil end
return math.floor(math.log10(math.abs(number)))
end
--------------------------------------------------------------------------------
-- Functions for calculating age
--------------------------------------------------------------------------------
-- Returns age in years and days. Input is two dates in numeric form as returned from os.time
function p.ageInYearsAndDays(date2N, date1N)
local date1 = os.date('!*t', date1N)
local date2 = os.date('!*t', date2N)
local age = {}
age.years = date2.year - date1.year;
if date2.month < date1.month or date2.month == date1.month and date2.day < date1.day then
age.years = age.years - 1
end
local year = date2.year
if date2.month < date1.month or date2.month == date1.month and date2.day < date1.day then
year = year - 1
end
age.days = gsd(date2.year, date2.month, date2.day) - gsd(year, date1.month, date1.day)
return age
end
--------------------------------------------------------------------------------
-- Functions for comparing ages
--------------------------------------------------------------------------------
-- Returns < 0 if ageA < ageB, 0 if ageA == ageB, > 0 if ageA > ageB
function p.compareAges(ageA, ageB)
if ageA.years ~= ageB.years then
if ageA.years < ageB.years then return -1 end
return 1
end
if ageA.days ~= ageB.days then
if ageA.days < ageB.days then return -1 end
return 1
end
return 0 -- equal
end
-- Returns true if ageA == ageB
function p.equalAges(ageA, ageB)
return p.compareAges(ageA, ageB) == 0
end
--------------------------------------------------------------------------------
-- Functions for displaying age
--------------------------------------------------------------------------------
-- Returns a date as a sortable string with age in years and days ("x aasta(t), y päev(a)")
function p.ageInYearsAndDaysFormat(age)
local result = tostring(age.years) .. ' ' .. (age.years == 1 and 'aasta' or 'aastat')
.. ', ' .. tostring(age.days) .. ' ' .. (age.days == 1 and 'päev' or 'päeva')
return '<span data-sort-value="' .. tostring(1000 * age.years + age.days) .. '">' .. result .. '</span>'
end
return p
i9uieh4qb7ubiene9nfo6on74k7dowz
Modul:Age utilities
0
11233
61371
2026-04-08T06:18:41Z
A.sav
6365
A.sav moved axa [[Modul:Age utilities]] yi [[Module:Age utilities]]: Misspelled title
61371
wikitext
text/x-wiki
#REDIRECT [[Module:Age utilities]]
cvl6aez9gu0xxydb5wrxrhgkdtsgljc