Content deleted Content added
BrandonXLF (talk | contribs) |
BrandonXLF (talk | contribs) →Template-protected edit request on 8 August 2018: new section |
||
Line 35:
dst_abbr = 'HDT',
</pre>
== Template-protected edit request on 8 August 2018 ==
{{edit template-protected|Module:Time|answered=no}}
local function get_utc_offset_hour (timezone)
local hours;
hours = mw.ustring.match (tz[timezone].utc_offset, '[+-±−]?(%d%d):%d%d');
return hours;
end
local function get_utc_offset_min (timezone)
local minutes;
minutes = mw.ustring.match (tz[timezone].utc_offset, '[+-±−]?%d%d:(%d%d)');
return minutes;
end
local function get_utc_offset_sign (timezone)
local sign;
sign = mw.ustring.match (tz[timezone].utc_offset, '([%+%-±−]?)%d%d:%d%d');
if '-' == sign then sign = '-'; else sign = '+'; end
return sign;
end
function p.offset (frame)
local args = getArgs(frame);
local utc_offset_hour;
local utc_offset_min;
local utc_offset_sign;
if args[1] then
args[1] = args[1]:lower();
if mw.ustring.match (args[1], 'utc[%+%-±−]?%d%d:%d%d') then
args[1] = 'utc_offsets';
end
if not is_set (tz[args[1]]) then
return '<span style="font-size:100%" class="error">{{time}} – unknown timezone ([[Template:Time#Error messages|help]])</span>';
end
else
args[1] = 'utc';
end
utc_offset_hour = get_utc_offset_hour (args[1]);
utc_offset_min = get_utc_offset_min (args[1]);
utc_offset_sign = get_utc_offset_sign (args[1]);
return string.format ('[[UTC%s%s:%s]]', utc_offset_sign, utc_offset_hour, utc_offset_min);
end
* These edits add a function which allows the module to output the UTC offset of a timezone. The output would be able to replace many templates and would allow [[Template:Infobox time zone]] to work more reliably. I've done testing to make sure both positive and negative UTC offsets work and function time still works [[User:BrandonXLF/sandbox2|here]]. — [[User:BrandonXLF|<span style="outline: 3px double blue;color:lightcyan;background-color:black;'> '''''BrandonXLF''''' </span>]] [[User talk:BrandonXLF|<sup>(t@lk)</sup>]] <span style="color:black"><sup>([[Template:Ping|ping back]])</sup></span> 15:34, 8 August 2018 (UTC)
|