Module:Infobox/dates
local getArgs = require('Module:Arguments').getArgs
local p = {}
function p.dates(frame)
local returnval;
local args = getArgs(frame);
if table.getn(args) < 2 then
if args['1'] == nil and args['2'] == nil then
return '';
elseif args['1'] == nil then
return args['2'];
elseif args['2'] == nil then
return args['1'];
end
end
args['1'] = args['1']:gsub(" "," ");
args['2'] = args['2']:gsub(" "," ");
local dmy = false;
local pr1, m1, d1, y1, su1 = string.match(args['1'], '(.-)(%u%a+)%s(%d+),%s(%d+)(.*)');
local pr2, m2, d2, y2, su2 = string.match(args['2'], '(.-)(%u%a+)%s(%d+),%s(%d+)(.*)');
if y1 == nil then
dmy = true;
pr1, d1, m1, y1, su1 = string.match(args['1'], '(.-)(%d%d?)%s(%a+)%s(%d+)(.*)');
pr2, d2, m2, y2, su2 = string.match(args['2'], '(.-)(%d%d?)%s(%a+)%s(%d+)(.*)');
end
local dash = ' – ';
if y1 ~= nil and y2 ~= nil then
su1 = su1 or '';
su2 = su2 or '';
local MONTHS = {Januar=1, Februar=2, Mairch=3, Apryle=4, Mey=5, Juin=6, Julie=7, August=8, September=9, October=10, November=11, December=12};
local diff = os.time({year=y2,month=MONTHS[m2],day=d2,hour=0,min=0,sec=0})-os.time({year=y1,month=MONTHS[m1],day=d1,hour=0,min=0,sec=0});
if diff < 0 then
returnval = 'Invalid date range';
else
if y1 == y2 then
if dmy == false then
returnval = pr1..m1..' '..d1..su1..dash..pr2..m2..' '..d2..', '..y2..su2;
else
returnval = pr1..d1..' '..m1..su1..dash..pr2..d2..' '..m2..' '..y2..su2;
end
else
if dmy == false then
returnval = pr1..m1..' '..d1..', '..y1..su1..dash..pr2..m2..' '..d2..', '..y2..su2;
else
returnval = pr1..d1..' '..m1..' '..y1..su1..dash..pr2..d2..' '..m2..' '..y2..su2;
end
end
end
else
returnval = args['1']..dash..args['2'];
end
return returnval;
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.