మాడ్యూల్:Citation/CS1/Date validation: కూర్పుల మధ్య తేడాలు

Content deleted Content added
synch from sandbox;
synch from sandbox;
పంక్తి 744:
local function reformat_dates (date_parameters_list, format, short)
local all = false; -- set to false to skip access- and archive-dates
local result = false;
local format_str;
local source_date = {};
Line 753 ⟶ 754:
for param_name, param_val in pairs (date_parameters_list) do -- for each date-holding parameter in the list
if is_set (param_val.val) then -- if the parameter has a value
if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then -- ifskip access- or archive-date andunless format notis xxx-all; yeah, ugly; TODO: find a better way
for source, pattern in pairs (source_patterns) do
param_val.val = ''; -- set to empty string so we don't process this date
if param_val.val:match (pattern) then
end
elseif if 'mdyymd' == source then
for source, pattern in pairs (source_patterns) do
get_mdy_date_parts get_ymd_date_parts (param_val.val, source_date); -- get the date parts into the source_date table
if param_val.val:match (pattern) then
if elseif 'ymddmy' == source then
get_ymd_date_parts get_dmy_date_parts (param_val.val, source_date); -- get the date parts into the source_date table
elseif 'dmymdy' == source then
get_dmy_date_parts get_mdy_date_parts (param_val.val, source_date); -- get the date parts into the source_date table
end
elseif 'mdy' == source then
get_mdy_date_parts (param_val.val, source_date); -- get the date parts into the source_date table
if 'ymd' == format and 1582 > tonumber(source_date.year) then -- ymd format dates not allowed before 1582
end
return false; -- abandon reformatting
 
end
if 'ymd' == format and 1582 > tonumber(source_date.year) then -- ymd format dates not allowed before 1582
return false; -- abandon reformatting
end if short then
format_str = long_formatsshort_formats[format];
if short then else
format_str = short_formatslong_formats[format];
else end
-- convert date and save;
format_str = long_formats[format];
date_parameters_list[param_name].val = mw.text.trim (os.date (format_str, os.time(source_date))); -- strip leading space when single digit day and %e is first format
end
result = true;
-- convert date and save;
end -- if
date_parameters_list[param_name].val = mw.text.trim (os.date (format_str, os.time(source_date))); -- strip leading space when single digit day and %e is first format
end -- for
end -- if
end -- if
end -- for
return trueresult; -- declare successresult and done
end