మాడ్యూల్: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 not (not all and in_array (param_name, {'access-date', 'archive-date'})) then --
for source, pattern in pairs (source_patterns) do▼
if param_val.val:match (pattern) then▼
end▼
▲ for source, pattern in pairs (source_patterns) do
▲ if param_val.val:match (pattern) then
elseif '
▲ 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
format_str =
-- 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
end
|