User:Matthiaspaul/sandbox/Module:Citation/CS1/Configuration

local df_template_patterns = {													-- table of redirects to and '{{ *[Uu]se +(dmy) +dates *[|}]',	-- 1159k								-- sorted by approximate transclusion count '{{ *[Uu]se +(mdy) +dates *[|}]',	-- 212k '{{ *[Uu]se +(MDY) +dates *[|}]',	-- 788 '{{ *[Uu]se +(DMY) +dates *[|}]',	-- 343 '{{ *([Mm]dy) *[|}]',				-- 176 '{{ *[Uu]se *(dmy) *[|}]',			-- 156 + 18 --	'{{ *[Uu]se(dmy) *[|}]', '{{ *[Uu]se *(mdy) *[|}]',			-- 149 + 11 --	'{{ *[Uu]se(mdy) *[|}]', '{{ *([Dd]my) *[|}]',				-- 56 '{{ *[Uu]se +(MDY) *[|}]',			-- 5 '{{ *([Dd]MY) *[|}]',				-- 3 '{{ *[Uu]se(mdy)dates *[|}]',		-- 1 '{{ *[Uu]se +(DMY) *[|}]',			-- 0 '{{ *([Mm]DY) *[|}]',				-- 0 }

local function get_date_format local content = mw.title.getCurrentTitle:getContent or ;				-- get the content of the article or ; new pages edited w/ve do not have 'content' until saved; ve does not preview; phab:T221625 for _, pattern in ipairs (df_template_patterns) do							-- loop through the patterns looking for or  or any of their redirects local start, _, match = content:find(pattern);							-- match is the three letters indicating desired date format if match then content = content:match ('%b{}', start);							-- get the whole template if content:match ('| *cs1%-dates *= *[lsy][sy]?') then				-- look for |cs1-dates=publication date length access-/archive-date length return match:lower .. '-' .. content:match ('| *cs1%-dates *= *([lsy][sy]?)'); else return match:lower .. '-all';									-- no |cs1-dates= k/v pair; return value appropriate for use in |df= end end end end

local global_df = get_date_format ;