Modul:Citation/CS1/Date validation/sandkasse: Forskelle mellem versioner

Content deleted Content added
Test 4
Tag: Tilbagerullet
Forsøg hvor jeg erstatter de nye kode fra enwiki med den gamle fra dawiki
Tag: Tilbagerullet
Linje 1.045:
]]
 
--[[-- MGA73: Ny kode fra enwiki
local function date_hyphen_to_dash (date_parameters_list)
local result = false;
Line 1.051 ⟶ 1.052:
if is_set (param_val.val) and
not mw.ustring.match (param_val.val, patterns.ymd[1]) then -- for those that are not ymd dates (ustring because here digits may not be Western)
param_val.val, n = param_val.val:gsub ('%-', '¤'); -- replace any hyphen with ndash
if 0 ~= n then
date_parameters_list[param_name].val = param_val.val; -- update the list
Line 1.060 ⟶ 1.061:
return result; -- so we know if any hyphens were replaced
end
]]
 
-- MGA73: Nedenfor kommer den gamle kode fra dawiki
local function date_hyphen_to_dash (date_parameters_list)
local result = false;
local n;
for param_name, param_val in pairs(date_parameters_list) do -- for each date-holding parameter in the list
if not param_val:match ('^[1-9]%d%d%d *%- *[1-9]%d%d%d') and
not param_val:match ('%d%d%d%d%-%d%d%-%d%d') and
not param_val:match ('%d%d%-%d%d%-%d%d%d%d') and
not param_val:match ('%d%d?%/%d%d?[%s-]%d%d%d%d') then
param_val, n = param_val:gsub ('%-', ' – '); -- replace any hyphen with ndash
if 0 ~= n then
date_parameters_list[param_name] = param_val; -- update the list
result = true;
end
end
if not param_val:match ('[1-9]%d?%. +%a+%.? *– *[1-9]%d?%. +%a+%.? +[1-9]%d%d%d') and
not param_val:match ('[1-9]%d?%. +%a+%.? +[1-9]%d%d%d *– *[1-9]%d?%. +%a+%.? +[1-9]%d%d%d') and
not param_val:match ('^%a+%.? +[1-9]%d%d%d *– *%a+%.? +[1-9]%d%d%d') then
param_val, n = param_val:gsub (' *– *', '-'); -- erstat tankestreg med bindestreg
if 0 ~= n then
date_parameters_list[param_name] = param_val; -- update the list
result = true;
end
end
if param_val:match ('[^ ]–[^ ]') then
param_val, n = param_val:gsub ('–', ' – ');
if 0 ~= n then
date_parameters_list[param_name] = param_val; -- update the list
result = true;
end
end
if param_val:match (' %- ') then
param_val, n = param_val:gsub (' +%- +', '-');
if 0 ~= n then
date_parameters_list[param_name] = param_val; -- update the list
result = true;
end
end
end
return result; -- so we know if
end
 
--[[--------------------------< E D T F _ T R A N S F O R M >--------------------------------------------------