Module:Complex date/sandbox: Difference between revisions

Content deleted Content added
adjust whitespaces
No edit summary
Line 21:
local i18n = require('Module:i18n/complex date') -- used for translations of date related phrases
local ISOdate = require('Module:ISOdate')._ISOdate -- used for parsing dates in YYYY-MM-DD and related formats
local Calendar -- loaded lazily
local formatnum = require('Module:Formatnum').formatNum -- used for translation into other alphabets
local Calendar = require('Module:Calendar') -- used for conversions between Julian and Gregorian calendar dates
 
-- ==================================================
Line 45 ⟶ 44:
local LList = {bn=1,bpy=1,kn=1,hi=1,mr=1,new=1,pa=1,gu=1,fa=1,glk=1,mzn=1,ur=1,ar=1,ckb=1,ks=1,lo=1,['or']=1,bo=1,['ml-old']=1,mn=1,te=1,th=1}
if LList[lang] then -- call only when the language is on the list
numStr = formatnumrequire('Module:Formatnum').formatNum(numStr, lang, 1)
end
return numStr
Line 168 ⟶ 167:
elseif operation == 'julian' then
if not date2 and date1 then -- Convert from Julian to Gregorian calendar date
if Calendar == nil then
Calendar = require("Module:Calendar") -- lazy loding (only if needed)
end
local JDN = Calendar._date2jdn(date1, 0)
if JDN then
Line 179 ⟶ 181:
dateStr = mw.ustring.gsub(mw.ustring.gsub(dateStr, '%( ', '('), ' %)', ')') -- in case date2 is empty
elseif operation == 'turn of the year' or operation == 'turn of the decade' or operation == 'turn of the century' then
local dt = 1;
if operation == 'turn of the decade' then dt=10 end
if not date2 or date2=='' then date2=tostring(tonumber(date1)-dt) end
Line 231 ⟶ 233:
-- based on string or numeric input calculate "Units" and "precision"
local precision
local dateNum = tonumber(dateStr);
if type(units)=='number' then
precision = units
Line 241 ⟶ 243:
end
elseif type(units)=='string' then
units = string.lower(units);
if units=='millennium' then precision=6
elseif units=='century' then precision=7