Module:Citation/CS1/Date validation: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
synch from sandbox; |
synch from sandbox; |
||
Line 744: | Line 744: | ||
local function reformat_dates (date_parameters_list, format, short) |
local function reformat_dates (date_parameters_list, format, short) |
||
local all = false; -- set to false to skip access- and archive-dates |
local all = false; -- set to false to skip access- and archive-dates |
||
local result = false; |
|||
local format_str; |
local format_str; |
||
local source_date = {}; |
local source_date = {}; |
||
Line 753: | Line 754: | ||
for param_name, param_val in pairs (date_parameters_list) do -- for each date-holding parameter in the list |
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 is_set (param_val.val) then -- if the parameter has a value |
||
if not all and in_array (param_name, {'access-date', 'archive-date'}) then -- |
if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then -- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way |
||
⚫ | |||
param_val.val = ''; -- set to empty string so we don't process this date |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
elseif 'dmy' == source then |
|||
get_dmy_date_parts (param_val.val, source_date); -- get the date parts into the source_date table |
|||
elseif ' |
elseif 'mdy' == source then |
||
get_mdy_date_parts (param_val.val, source_date); -- get the date parts into the source_date table |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
if short then |
|||
⚫ | |||
⚫ | |||
else |
|||
format_str = |
format_str = long_formats[format]; |
||
end |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
result = true; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end -- for |
||
end |
end -- if |
||
end |
end -- if |
||
end |
end -- for |
||
return result; -- declare result and done |
|||
end |
end |
||