Module talk:Time

This is an old revision of this page, as edited by Trappist the monk (talk | contribs) at 16:37, 8 August 2018 (Template-protected edit request on 8 August 2018). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Latest comment: 7 years ago by Trappist the monk in topic Template-protected edit request on 8 August 2018

Shortin month

@Trappist the monk: I think we should shortin the month names to allow for use on Template:Datetime and to keep other templaes short aswell. --★BrandonALF★ talk edits 22:41, 16 December 2017 (UTC)Reply

It looks to me like you have broken existing uses of {{datetime}}. Please revert your changes there.
Trappist the monk (talk) 22:59, 16 December 2017 (UTC)Reply
@Trappist the monk: I'm sorry, I didn't realize that was there. So now I need to do my edit for Template:Local time --★BrandonALF★ talk edits 23:06, 16 December 2017 (UTC)Reply
Thank you. There are 1000+, mostly user pages, that use {{time}} and so use this module. Given that, it would seem to me that you either accept long month names or find a way to tell the module to abbreviate specific {{#invoke:}} instances. You don't just decide for everyone that from now on the date will render as an abbreviation.
Trappist the monk (talk) 23:26, 16 December 2017 (UTC)Reply
I have raised the protection level of this module to require WP:Template editor permission because you have elected to edit war instead of discuss. Feel free to use sandboxen for your template development. Also, use testcases pages to do testing before adding your template to mainspace articles. Testing as you have been doing is considered disruptive and may result in your editing privileges being restricted or revoked.
Trappist the monk (talk) 00:00, 17 December 2017 (UTC)Reply

Documentation

Hey I just discovered this module after I saw it was used on a table at the NFL playoffs article and would like an explanation as to how it works. –Piranha249 (talk) 02:03, 9 January 2018 (UTC)Reply

I think that you are mistaken. This module is not used at NFL playoffs. You can prove this to your self. Follow this link. Below the Publish changes button you will see 'Pages transcluded onto the current version of this page'. Click that to get a list of all templates and modules transcluded in NFL playoffs. Module:Time is not there.
What you are seeing is the #time parser function.
Trappist the monk (talk) 02:22, 9 January 2018 (UTC)Reply
Oh, I thought it was there, but I forgot the modules start with Invoke. –Piranha249 (talk) 02:32, 9 January 2018 (UTC)Reply

Abbreviations for Hawaii-Aleutian time zones are wrong

Someone recently changed the Hawaii–Aleutian Time Zone page to have the abbreviations HAST/HADT in the infobox for time zone (North America) to match the abbreviations here, but the abbreviations are wrong. Please see references on that page. The correct abbreviations are HST/HDT, and are what were in the page beforehand. The abbreviations used here are incorrect also. The lines that read:

['hast'] = {	-- same as AleutST and HST
 abbr = 'HAST',
 dst_abbr = 'HADT',

need to be changed to:

['hst'] = {	-- same as AleutST
 abbr = 'HST',	-- note: not HAST or HADT
 dst_abbr = 'HDT',

Template-protected edit request on 8 August 2018

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
I added <syntaxhighlight>...</syntaxhighlight> to make your code more readable. How does this change make {{Infobox time zone}} work more reliably? If that template is 'unreliable', shouldn't fixes be applied there? Why is your proposed code so complex? Can't it be made simpler?
Trappist the monk (talk) 16:04, 8 August 2018 (UTC)Reply
Wouldn't this work just as well?
function p.offset (frame)
	local args = getArgs(frame);
	if args[1] then
		args[1] = args[1]:lower();												
	
		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
	end
	
	return table.concat ({'[[UTC', tz[args[1]].utc_offset:gsub ('^(%d)', '+%1'):gsub ('^-', '−'), ']]'});
	end
Trappist the monk (talk) 16:37, 8 August 2018 (UTC)Reply