Jump to content

Module talk:Time

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from Module talk:Time/sandbox)

Shortin month

[edit]

@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

[edit]

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

[edit]

The page on Hawaii–Aleutian Time Zone was changed recently to have the abbreviations HAST/HADT in the infobox, which are incorrect. The infoxbox references this module. The correct abbreviations are HST/HDT, but the reason why it was changed is because this module does not have HST/HDT. To fix this, 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',

Mordomo (talk) 12:54, 11 August 2018 (UTC)[reply]

Template-protected edit request on 8 August 2018

[edit]
Extended content
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?
Extended content
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]

@Trappist the monk: Yes it would, because it's smaller and more efficient I prefer if your code is added. It makes {{Infobox time zone}} more reliable because currently it's using a template that doesn't have a lot of timezone, where as Module:time as a lot of time zones already. —  BrandonXLF   (t@lk) (ping back) 16:51, 8 August 2018 (UTC)[reply]

You are speaking of {{Timezoneoffset}}? Looks to me like there are 155 timezones listed. That number is rather more than the number listed in Module:Time.
Trappist the monk (talk) 17:04, 8 August 2018 (UTC)[reply]
@Trappist the monk: Sorry, I forgot I switch it back to use that tempalte, but the issue is there's many repeated abbreviation and rather then breaking the template into DST and non DST it would be easier to add this function, besides the infobox already uses module:time to display the time of the timezone. —  BrandonXLF   (t@lk) (ping back) 17:10, 8 August 2018 (UTC)[reply]
I'm confused. You created that template which does support DST, something that p.offset() won't. If there are repeated abbreviation[s] then isn't it a simple matter of locating and excising those? I could imagine translating the information in {{Timezoneoffset}} into a Lua table and then having p.offset() mw.loadData() and use that table instead of using the tz{} table. Later, tz{} might be adapted to use the offsets{} table.
Trappist the monk (talk) 10:33, 9 August 2018 (UTC)[reply]
@Trappist the monk: I'll figure something out. —  BrandonXLF   (t@lk) (ping back) 14:27, 9 August 2018 (UTC)[reply]
Related to the above, I have moved the /sandbox data table to Module:Time/data/sandbox. This ought to make is easier to create a utc offsets table and function.
Trappist the monk (talk) 15:10, 11 August 2018 (UTC)[reply]

Template-protected edit request on 9 August 2018

[edit]

replace p.time with

Extended content
function p.time (frame)
	local args = getArgs(frame);
	local utc_timestamp, timestamp;												-- current or _TEST_TIME_ timestamps; timestamp is local ST or DST time used in output
	local dst_begin_ts, dst_end_ts;												-- DST begin and end timestamps in UTC
	local tz_abbr;																-- select ST or DST timezone abbreviaion used in output 
	local tz_string;															-- output time in |df= format
	local utc_offset;
	local invert;																-- true when southern hemisphere
	local df;																	-- date format flag; the |df= parameter
	local hf;                                                                   -- hour format flag; derived from the |df=dmy12 and |df=mdy12 parameters
	local timeonly;
	local dateonly;
	
	if args[1] then
		args[1] = args[1]:lower();												-- make lower case because tz table member indexes are lower case

		if mw.ustring.match (args[1], 'utc[%+%-±−]?%d%d:%d%d') then				-- if rendering time for a UTC offset timezone
			tz['utc_offsets'].abbr = args[1]:upper():gsub('%-', '−');			-- set the link label to upper case and replace hyphen with a minus character (U+2212)
			tz['utc_offsets'].article = tz['utc_offsets'].abbr;					-- article title same as abbreviation
			tz['utc_offsets'].utc_offset = mw.ustring.match (args[1], 'utc([%+%-±−]?%d%d:%d%d)'):gsub('−', '%-');	-- extract the offset value; replace minus character with hyphen
			args[1] = 'utc_offsets';											-- point to the generic utc offsets table 
		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';														-- default to utc
	end
	
	timeonly = args.timeonly;
	dateonly = args.dateonly;
	
	df = args.df or args[2] or tz[args[1]].df or '';							-- template |df= overrides typical df from tz properties TODO: error check these values?
	if is_set (df) then
		df = df:lower();														-- lower case because we will compare to lower case values later
	end

	hf = df:match ('%l%ly(12)');												-- hf == '12' selects 12-hour AM/PM display; other values ignored and 24 hour clock time displayed 
	if is_set (hf) then
		df = df:match ('(%l%ly)12');											-- extract df
	end

	if is_set (args._TEST_TIME_) then											-- typically used to test the code at a specific utc time
		local test_time = get_test_time (args._TEST_TIME_);
		if not test_time then
			return '<span style="font-size:100%" class="error">{{time}} – malformed or incomplete _TEST_TIME_ ([[Template:Time#Error messages|help]])</span>';
		end

--		utc_timestamp = os.time(get_test_time (args._TEST_TIME_));
		utc_timestamp = os.time(test_time);
	else
		utc_timestamp = os.time ();												-- get current server time (UTC)
	end
	utc_offset = get_utc_offset (args[1]);										-- utc offset for specified timezone
	timestamp = utc_timestamp + utc_offset;										-- make local time timestamp

	if 'no' == args.dst then													-- for timezones that DO observe dst but for this location ...
		tz_abbr = tz[args[1]].abbr;												-- ... dst is not observed (|dst=no) show time as standard time
	else
		if is_set (tz[args[1]].dst_begins) and is_set (tz[args[1]].dst_ends) and is_set (tz[args[1]].dst_time) then		-- make sure we have all of the parts
			dst_begin_ts, dst_end_ts, invert = make_dst_timestamps (timestamp, args[1]);	-- get begin and end dst timestamps and invert flag

			if nil == dst_begin_ts or nil == dst_end_ts then
				return '<span style="font-size:100%" class="error">{{time}} – error calculating dst timestamps ([[Template:Time#Error messages|help]])</span>';
			end
	
			if invert then														-- southern hemisphere; use beginning and ending of standard time in the comparison
				if utc_timestamp >= dst_end_ts and utc_timestamp < dst_begin_ts then	-- is current date time standard time?
					tz_abbr = tz[args[1]].abbr;									-- standard time abbreviation
				else		
					timestamp = timestamp + 3600;								-- add an hour for 
					tz_abbr = tz[args[1]].dst_abbr;								-- dst abbreviation
				end
			else																-- northern hemisphere
				if utc_timestamp >= dst_begin_ts and utc_timestamp < dst_end_ts then	-- all timestamps are UTC
					timestamp = timestamp + 3600;								-- add an hour
					tz_abbr = tz[args[1]].dst_abbr;
				else
					tz_abbr = tz[args[1]].abbr;
				end
			end
		elseif is_set (tz[args[1]].dst_begins) or is_set (tz[args[1]].dst_ends) or is_set (tz[args[1]].dst_time) then	-- if some but not all not all parts then emit error message
			return '<span style="font-size:100%" class="error">{{time}} – incomplete definition for ' .. args[1]:upper() .. ' ([[Template:Time#Error messages|help]])</span>';
		else
			tz_abbr = tz[args[1]].abbr;											-- dst not observed for this timezone
		end
	end
	
	if 'yes' == timeonly then
		if '12' == hf then
			tz_string = mw.text.trim (os.date ('%l:%M %p'));
		else
			tz_string = os.date ('%R');	
		end
	elseif 'yes' == dateonly then
		if 'dmy' == hf or 'y' == df then
			tz_string = mw.text.trim (os.date ('%e %B %Y', timestamp));
		else
			tz_string = os.date ('%B %e %Y', timestamp);	
		end
	else
		if 'y' == df or 'dmy' == df then											-- format the output (|df=y is legacy from original template)
			if '12' == hf then
				tz_string = mw.text.trim (os.date ('%l:%M %p, %e %B %Y', timestamp));	-- dmy, 12 hour am/pm
			else
				tz_string = os.date ('%R, %e %B %Y', timestamp);					-- dmy
			end
		elseif 'iso' == df then
			tz_string = os.date ('%FT%R', timestamp);								-- iso
		else
			if '12' == hf then
				tz_string = mw.text.trim (os.date ('%l:%M %p, %B %e, %Y', timestamp));	-- mdy (legacy default)
			else
				tz_string = os.date ('%R, %B %e, %Y', timestamp);					-- mdy (legacy default)
			end
		end
	end

	if not is_set (tz[args[1]].article) then									-- if some but not all not all parts then emit error message
		return '<span style="font-size:100%" class="error">{{time}} – incomplete definition for ' .. args[1]:upper() .. ' ([[Template:Time#Error messages|help]])</span>';
	end
	
	local refreshLink = mw.title.getCurrentTitle():fullUrl{action = 'purge'}	-- create a refresh link
	return string.format ('%s [[%s|%s]] <span class="plainlinks" style="font-size:80%%;">[[%s refresh]]</span>', tz_string, tz[args[1]].article, tz_abbr, refreshLink);
end

What it does is add parameters timeonly and dateonly, which allows the module to output the time or date of an timezone. This would be very helpful in the userspace and in some templates. —  BrandonXLF   (t@lk) (ping back) 20:46, 9 August 2018 (UTC)[reply]

Not ready, methinks:
  • {{#invoke:time/sandbox|time|dateonly=yes}} → 19 November 2024 UTC [refresh]
  • {{#invoke:time/sandbox|time|dateonly=yes|df=dmy}} → 19 November 2024 UTC [refresh]
  • {{#invoke:time/sandbox|time|dateonly=yes|df=mdy}} → November 19, 2024 UTC [refresh]
  • {{#invoke:time/sandbox|time|dateonly=yes|df=y}} → 19 November 2024 UTC [refresh]
  • {{#invoke:time/sandbox|time|dateonly=yes|df=iso}} → 2024-11-19 UTC [refresh]
Trappist the monk (talk) 21:13, 9 August 2018 (UTC)[reply]
@Trappist the monk: Fixed the issues from above:
Extended content
function p.time (frame)
	local args = getArgs(frame);
	local utc_timestamp, timestamp;												-- current or _TEST_TIME_ timestamps; timestamp is local ST or DST time used in output
	local dst_begin_ts, dst_end_ts;												-- DST begin and end timestamps in UTC
	local tz_abbr;																-- select ST or DST timezone abbreviaion used in output 
	local tz_string;															-- output time in |df= format
	local utc_offset;
	local invert;																-- true when southern hemisphere
	local df;																	-- date format flag; the |df= parameter
	local hf;                                                                   -- hour format flag; derived from the |df=dmy12 and |df=mdy12 parameters
	local timeonly;
	local dateonly;
	
	if args[1] then
		args[1] = args[1]:lower();												-- make lower case because tz table member indexes are lower case

		if mw.ustring.match (args[1], 'utc[%+%-±−]?%d%d:%d%d') then				-- if rendering time for a UTC offset timezone
			tz['utc_offsets'].abbr = args[1]:upper():gsub('%-', '−');			-- set the link label to upper case and replace hyphen with a minus character (U+2212)
			tz['utc_offsets'].article = tz['utc_offsets'].abbr;					-- article title same as abbreviation
			tz['utc_offsets'].utc_offset = mw.ustring.match (args[1], 'utc([%+%-±−]?%d%d:%d%d)'):gsub('−', '%-');	-- extract the offset value; replace minus character with hyphen
			args[1] = 'utc_offsets';											-- point to the generic utc offsets table 
		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';														-- default to utc
	end
	
	timeonly = args.timeonly;
	dateonly = args.dateonly;
	
	df = args.df or args[2] or tz[args[1]].df or '';							-- template |df= overrides typical df from tz properties TODO: error check these values?
	if is_set (df) then
		df = df:lower();														-- lower case because we will compare to lower case values later
	end

	hf = df:match ('%l%ly(12)');												-- hf == '12' selects 12-hour AM/PM display; other values ignored and 24 hour clock time displayed 
	if is_set (hf) then
		df = df:match ('(%l%ly)12');											-- extract df
	end

	if is_set (args._TEST_TIME_) then											-- typically used to test the code at a specific utc time
		local test_time = get_test_time (args._TEST_TIME_);
		if not test_time then
			return '<span style="font-size:100%" class="error">{{time}} – malformed or incomplete _TEST_TIME_ ([[Template:Time#Error messages|help]])</span>';
		end

--		utc_timestamp = os.time(get_test_time (args._TEST_TIME_));
		utc_timestamp = os.time(test_time);
	else
		utc_timestamp = os.time ();												-- get current server time (UTC)
	end
	utc_offset = get_utc_offset (args[1]);										-- utc offset for specified timezone
	timestamp = utc_timestamp + utc_offset;										-- make local time timestamp

	if 'no' == args.dst then													-- for timezones that DO observe dst but for this location ...
		tz_abbr = tz[args[1]].abbr;												-- ... dst is not observed (|dst=no) show time as standard time
	else
		if is_set (tz[args[1]].dst_begins) and is_set (tz[args[1]].dst_ends) and is_set (tz[args[1]].dst_time) then		-- make sure we have all of the parts
			dst_begin_ts, dst_end_ts, invert = make_dst_timestamps (timestamp, args[1]);	-- get begin and end dst timestamps and invert flag

			if nil == dst_begin_ts or nil == dst_end_ts then
				return '<span style="font-size:100%" class="error">{{time}} – error calculating dst timestamps ([[Template:Time#Error messages|help]])</span>';
			end
	
			if invert then														-- southern hemisphere; use beginning and ending of standard time in the comparison
				if utc_timestamp >= dst_end_ts and utc_timestamp < dst_begin_ts then	-- is current date time standard time?
					tz_abbr = tz[args[1]].abbr;									-- standard time abbreviation
				else		
					timestamp = timestamp + 3600;								-- add an hour for 
					tz_abbr = tz[args[1]].dst_abbr;								-- dst abbreviation
				end
			else																-- northern hemisphere
				if utc_timestamp >= dst_begin_ts and utc_timestamp < dst_end_ts then	-- all timestamps are UTC
					timestamp = timestamp + 3600;								-- add an hour
					tz_abbr = tz[args[1]].dst_abbr;
				else
					tz_abbr = tz[args[1]].abbr;
				end
			end
		elseif is_set (tz[args[1]].dst_begins) or is_set (tz[args[1]].dst_ends) or is_set (tz[args[1]].dst_time) then	-- if some but not all not all parts then emit error message
			return '<span style="font-size:100%" class="error">{{time}} – incomplete definition for ' .. args[1]:upper() .. ' ([[Template:Time#Error messages|help]])</span>';
		else
			tz_abbr = tz[args[1]].abbr;											-- dst not observed for this timezone
		end
	end
	
	if 'yes' == timeonly then
		if '12' == hf then
			tz_string = mw.text.trim (os.date ('%l:%M %p'));
		else
			tz_string = os.date ('%R');	
		end
	elseif 'yes' == dateonly then
		if 'dmy' == df or 'y' == df then
			tz_string = mw.text.trim (os.date ('%e %B %Y'));
		elseif 'iso' == df then
			tz_string = mw.text.trim (os.date ('%F'));
		else
			tz_string = os.date ('%B %e %Y');	
		end
	else
		if 'y' == df or 'dmy' == df then											-- format the output (|df=y is legacy from original template)
			if '12' == hf then
				tz_string = mw.text.trim (os.date ('%l:%M %p, %e %B %Y', timestamp));	-- dmy, 12 hour am/pm
			else
				tz_string = os.date ('%R, %e %B %Y', timestamp);					-- dmy
			end
		elseif 'iso' == df then
			tz_string = os.date ('%FT', timestamp);								-- iso
		else
			if '12' == hf then
				tz_string = mw.text.trim (os.date ('%l:%M %p, %B %e, %Y', timestamp));	-- mdy (legacy default)
			else
				tz_string = os.date ('%R, %B %e, %Y', timestamp);					-- mdy (legacy default)
			end
		end
	end

	if not is_set (tz[args[1]].article) then									-- if some but not all not all parts then emit error message
		return '<span style="font-size:100%" class="error">{{time}} – incomplete definition for ' .. args[1]:upper() .. ' ([[Template:Time#Error messages|help]])</span>';
	end
	
	local refreshLink = mw.title.getCurrentTitle():fullUrl{action = 'purge'}	-- create a refresh link
	if dateonly == 'yes' or timeonly == 'yes' then
		return string.format ('%s <span class="plainlinks" style="font-size:80%%;">[[%s refresh]]</span>', tz_string, refreshLink);
	else
		return string.format ('%s [[%s|%s]] <span class="plainlinks" style="font-size:80%%;">[[%s refresh]]</span>', tz_string, tz[args[1]].article, tz_abbr, refreshLink);
	end
end

 BrandonXLF   (t@lk) (ping back) 01:12, 10 August 2018 (UTC)[reply]

You didn't actually. I've rewritten that section of the code so that it is simpler. Here are some results:
time & date:
time only:
date only:
Trappist the monk (talk) 12:43, 10 August 2018 (UTC)[reply]
@Trappist the monk: That works too. I think that refresh link can be annoying as some need it in different places so I added |refresh= to the sandbox
 BrandonXLF   (t@lk) (ping back) 13:37, 10 August 2018 (UTC)[reply]
Tweaked that a bit. Why have you chosen to omitted the timezone abbreviation when |dateonly=yes and |timeonly=yes? It seems to me that the default rendering must include the timezone abbreviation else readers don't know where the time/date applies.
Trappist the monk (talk) 15:08, 10 August 2018 (UTC)[reply]
@Trappist the monk: I've chosen to ommit time timezone abbreviation because some templates are like "It's 21:30 where this user lives" If you want to include the abbreviation you can add a parameter like |abbrev= to include it or not. —  BrandonXLF   (t@lk) (ping back) 19:39, 10 August 2018 (UTC)[reply]
I added |show_tz=
 BrandonXLF   (t@lk) (ping back) 22:59, 10 August 2018 (UTC)[reply]

Parameter names and the internal variables that they feed should make sense when read and should indicate the action that will occur. |refresh=no was a poor choice because the word 'refresh' is a verb indicating action. As I used the variable refresh in the /sandbox, when true == refresh then render a refresh link. You reversed that to mean when false == refresh then render a refresh link. That's just confusing. I have renamed |refresh= to |hide-refresh=:

  • 6:34 pm, 18 November 2024 MST hide-refresh=yes
  • 6:34 pm, 18 November 2024 MST [refresh] hide-refresh=no
  • 6:34 pm, 18 November 2024 MST [refresh]

Similarly, I renamed |show_tz= to |hide-tz=:

  • 6:34 pm, 18 November 2024 [refresh] hide-tz=yes
  • 6:34 pm, 18 November 2024 MST [refresh] hide-tz=no
  • 6:34 pm, 18 November 2024 MST [refresh]

and while at it, created |unlink-tz=:

  • 6:34 pm, 18 November 2024 MST [refresh] unlink-tz=yes
  • 6:34 pm, 18 November 2024 MST [refresh] unlink-tz=no
  • 6:34 pm, 18 November 2024 MST [refresh]

Trappist the monk (talk) 12:01, 11 August 2018 (UTC)[reply]

@Trappist the monk: That makes more sense. Thanks. —  BrandonXLF   (t@lk) (ping back) 13:02, 11 August 2018 (UTC)[reply]
@Trappist the monk: Can you implement the code in the sandbox or do you have issues with it? —  BrandonXLF   (t@lk) (ping back) 19:25, 12 August 2018 (UTC)[reply]
If you mean update the live module, then, I can – when you are done with the sandbox.
Trappist the monk (talk) 08:58, 13 August 2018 (UTC)[reply]
@Trappist the monk: I made a few changes in the sandbox and I updated the documentation. If you have any issues let me know, else I'm done with the sandbox.—  BrandonXLF   (t@lk) (ping back) 16:16, 15 August 2018 (UTC)[reply]
Looks to me like you broke |hide-refresh=, |hide-tz=, and |unlink-tz= so I have repaired those. I don't think that you should have deleted |timeonly= so I have restored that. You created a new but malformed and extraneous p.time() so I deleted that, renamed _time() to time() and restored the export table.
You continued to make changes after you had said that you were done so how am I to believe that you really are done?
Trappist the monk (talk) 12:07, 16 August 2018 (UTC)[reply]
@Trappist the monk: Everything is working properly and you made your final edits, so I'm done with the sandbox. Really this time. —  BrandonXLF   (t@lk) (ping back) 13:02, 16 August 2018 (UTC)[reply]
 Done
Trappist the monk (talk) 13:21, 17 August 2018 (UTC)[reply]

Template-protected edit request on 15 August 2018

[edit]

Hi, Kindly help to add the time zone for Singapore. Thank you.

['sst'] = { abbr = 'SST', dst_abbr = '', utc_offset = '08:00', df = 'dmy', dst_begins = '', dst_ends = '', dst_time = '', article = 'Time in Singapore' Fiipchip (talk) 09:56, 15 August 2018 (UTC)[reply]

 Done
Trappist the monk (talk) 10:55, 15 August 2018 (UTC)[reply]

Template-protected edit request on 3 September 2018

[edit]

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


I've made some edits to the sandbox (diff) and data/sandbox (diff). These edits add support for DST timezone such as EST and other names that timezone are known as (the list is small right now) such as ET. It also adds more support for UTC offsets so +5, -5 ,+05, -05:30, -5.5 all work with it. A test page can be seen at User:BrandonXLF/sandbox/5. – BrandonXLF (t@lk) 02:33, 3 September 2018 (UTC)[reply]

where is the need for the module to support dst timezone abbreviations as primary inputs? where is the need to display dst time during non-dst periods (edt in January)? where is the need for all of these variations on the utc offset theme? doesn't work for bst and ist because these abbreviations are already in use – i didn't check the rest.
Trappist the monk (talk) 03:10, 3 September 2018 (UTC)[reply]
@Trappist the monk:There're some templates the currently use a ineffecient system of getting information, for these templates to have any chance of using the module these have to be supported, also it make the module much more useful and easier to use. – BrandonXLF (t@lk) 03:30, 3 September 2018 (UTC)[reply]
What templates? How do these changes make the module much more useful and easier to use?
Trappist the monk (talk) 11:03, 3 September 2018 (UTC)[reply]
@Trappist the monk:It's more convient when you don't need to enter the full UTC offset and in some causes users may want the time of a DST timezone. Some templates that could switch over are {{Current minute in time zone}} and similar. And it just adds more functionality. – BrandonXLF (t@lk) 16:22, 3 September 2018 (UTC)[reply]
I might be persuaded that there is some sense in loosening the requirements for utc offset provided, however, that you do a better job with the code which is clearly not ready.
I am not persuaded that accepting dst timezone abbreviations is warranted. I might be persuaded that alternate standard (non-dst) abbreviations have some small benefit.
Trappist the monk (talk) 17:41, 3 September 2018 (UTC)[reply]
@Trappist the monk:But what harm does it do? If you're already making a edit why not include them in it? – BrandonXLF (t@lk) 19:46, 3 September 2018 (UTC)[reply]
Nonsense output as I mentioned before: when given a dst timezone abbreviation your code produces a dst time when dst is not in effect:
{{time/sandbox|EDT|_TEST_TIME_=2019-01-02T{{#time:H:i:s}}}} → 20:34, January 1, 2019 EST [refresh]
I also pointed out that BST is assigned to Bangladesh standard time so can't be used for British summer time and that IST is assigned to Indian standard time so can't be used for – I don't know what you intended IST for:
{{time/sandbox|BST}} → 07:34, 2 January 2019 BST [refresh] (time in Bangladesh)
{{time/sandbox|IST}} → 07:04, 2 January 2019 IST [refresh] (time in India)
Trappist the monk (talk) 11:06, 5 September 2018 (UTC)[reply]
@Trappist the monk:Ok, I removed IST and BST from the list, if you think it still has no use let me know and I'll remove it. Personally I think some people would find it useful, but you're the person making the edit in the end. As I said I'll gladly remove it if that's what you want. Also, please {{ping}} me when replying. Thanks, – BrandonXLF (t@lk) 22:52, 5 September 2018 (UTC)[reply]
@Trappist the monk:Note: The DST time zones output DST time even when it's not DST, because they are DST time zones and such always should output DST. – BrandonXLF (t@lk) 22:54, 5 September 2018 (UTC)[reply]
The DST time zones output DST time even when it's not DST. Yes, that is what your code does, and I think that it is nonsensical because dst implies that it has been switched from and will switch back to standard time (without researching it, I suspect that this is probably why Saskatchewan, which used to be in mst/mdt, is now considered to be in cst year round).
I can imagine supporting dst timezone abbreviations as aliases of standard timezone abbreviations (as long as the dst abbreviation doesn't conflict with an existing standard timezone abbreviation) which would cause the template's output to be rendered exactly the same for regardless of which abbreviation (dst or standard) is used.
Trappist the monk (talk) 13:12, 6 September 2018 (UTC)[reply]
Ok, sure I'll make then aliases instead of how they are. – BrandonXLF (t@lk) 20:22, 6 September 2018 (UTC)[reply]

@Trappist the monk: I made the DST offset aliases, I added more aliases, I made it so you can set dst=always for it to always be DST (takes very little code) and I removed all code that you said needed to be removed? Is it good now, I'm always happy to add suggestions. I also added HST as a seprate timezone as per #Abbreviations for Hawaii-Aleutian time zones are wrong and my own research. – BrandonXLF (t@lk) 20:32, 7 September 2018 (UTC)[reply]

The discussion above is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.

Template-protected edit request on 9 September 2018

[edit]

(@Trappist the monk:) A update to #Template-protected edit request on 3 September 2018, Replace the contents of Module:time with Module:time/sandbox (diff) and the contents of Module:time/data with Module:time/data/sandbox (diff). Examples of usage can be seen at User:BrandonXLF/sandbox/5. These edits add:
1) Aliases, extra abbreviations of timezones that allow for previous abbreviations that returned unknown to now return a timezone (including DST timezones)
2) More UTC offset support, allows for more support for UTC offsets (such as -5, +5 , +8:30 and -9.5 NEW: +6.4)
3) DOW, adds dow as a format in the format table (NEW)
Note: This edit also addresses #Abbreviations for Hawaii-Aleutian time zones are wrongBrandonXLF (t@lk) 00:56, 11 September 2018 (UTC)[reply]

In the previous discussion I did write: I might be persuaded that there is some sense in loosening the requirements for utc offset provided, however, that you do a better job with the code which is clearly not ready. You ignored that comment. For example:
{{time/sandbox|1.2}} → 2024-11-19T02:46 UTC+01:12 [refresh]
Trappist the monk (talk) 01:13, 9 September 2018 (UTC)[reply]
@Trappist the monk: I didn't even see part, my bad. I'll let you know when I do that, – BrandonXLF (t@lk) 15:02, 9 September 2018 (UTC)[reply]
@Trappist the monk: I fixed the code and made it simpler, any more suggestions? – BrandonXLF (t@lk) 18:57, 9 September 2018 (UTC)[reply]
Perhaps not:
{{time/sandbox|1.26}} → 2024-11-19T02:49 UTC+01:15 [refresh]
Trappist the monk (talk) 19:29, 9 September 2018 (UTC)[reply]
@Trappist the monk:The reason that doesn't work is because 1.26 = UTC+01:15.6 and you can't have a UTC offset of 1:15.6, if you'd like I can add a rounding function. So UTC1:15.6 ---> UTC1:16. Please let me know if I should add it. – BrandonXLF (t@lk) 19:41, 9 September 2018 (UTC)[reply]
The module should gracefully accept whatever it is given as input. The big red lua script error message is not graceful. So if I type:
{{time|bob}}
where there is not timezone called 'bob', the module should gracefully fail:
{{time}} – unknown timezone bob (help)
and it does but the sandbox doesn't:
{{time/sandbox|bob}}{{time}} – unknown timezone bob (help)
Trappist the monk (talk) 19:54, 9 September 2018 (UTC)[reply]
@Trappist the monk: I added an error code, is it good now? – BrandonXLF (t@lk) 20:02, 9 September 2018 (UTC)[reply]
@Trappist the monk: I got the error code working for {{time/sandbox|bob}} too, it looks like {{time}} – unknown timezone bob (help). Please let me know if you have any other suggestions. – BrandonXLF (t@lk) 00:15, 10 September 2018 (UTC)[reply]
@Trappist the monk: I made some monior fixes such as producing better error codes and accepting more logical inputs. I also added dow to the date format table, I think it could be useful. As far as this edit request goes I'm done unless you have any issues/suggestion about it
I have rewritten get_full_utc_offset() so that it is simpler and easier to understand. I removed the format specification because the default time display format is handled elsewhere. I do not think that it should be changed from its current iso format; |df= is there for those who wish a different format. Fractional hours to two digits are more-or-less properly supported by truncation:
{{time/sandbox|-6.17}} → 2024-11-18T19:24 UTC−06:10 [refresh]
Trappist the monk (talk) 12:05, 11 September 2018 (UTC)[reply]
@Trappist the monk: Everything looks fine, I'm done editing it. – BrandonXLF (t@lk) 12:47, 11 September 2018 (UTC)[reply]
@Trappist the monk: Is everything fine with the proposed edits? Any more questions about the proposed edits? I'm always happy to answer them. – BrandonXLF (t@lk) 00:51, 13 September 2018 (UTC)[reply]
Not done: please make your requested changes to the module's sandbox first; see WP:TESTCASES. Module:Time/testcases is empty and the tests in your sandbox show only the results from the sandbox, not a comparison of live & sandbox showing what your edits fix. You've used the tper template often enough to know which pages the tools link to, and where things ought to be. Cabayi (talk) 21:06, 23 September 2018 (UTC)[reply]
 Done as User:Trappist the monk implemented the changes in the sandbox. – BrandonXLF (t@lk) 16:40, 5 October 2018 (UTC)[reply]

why {timestamp}?

[edit]

@Tom.Reding: Why {{time|_TEST_TIME_={{timestamp}}}}? That gives the same results as {{time}} without parameters:

{{time|_TEST_TIME_={{timestamp}}}} → 01:34, 19 November 2024 UTC [refresh]
{{time}} → 01:34, 19 November 2024 UTC [refresh]
The purpose of |_TEST_TIME_= was/is to fix time for the purposes of debugging edge cases and ISO 8601 format is much easier to read than a 14-digit timestamp.

Trappist the monk (talk) 14:56, 6 February 2019 (UTC)[reply]

@Trappist the monk: if only for when {{timestamp}} is better off substituted, like for a delayed save with a hard-coded timestamp you'd like to format. I'm glad the testcase functionality was kept, since this fit the bill quite nicely (with timezones to boot). I can transfer this functionality to my sandbox if necessary, but I figured others might find it useful too at some point.   ~ Tom.Reding (talkdgaf)  15:33, 6 February 2019 (UTC)[reply]
Any time you want a hard-coded timestamp, actually. And I thought about making an ISO 8601 option for {{timestamp}} or even a {{TimestampISO8601}}, but this was easier, unless there's already a template that outputs that.   ~ Tom.Reding (talkdgaf)  15:38, 6 February 2019 (UTC)[reply]
{{#time:}} parser function?
{{#time:Y-m-d"T"H:i:s}} → 2024-11-19T01:34:10
Trappist the monk (talk) 15:58, 6 February 2019 (UTC)[reply]
Ah, yes that would also work. {{Timestamp}} is much more convenient and intuitively named, though.   ~ Tom.Reding (talkdgaf)  16:17, 6 February 2019 (UTC)[reply]

How to revert time section?

[edit]

Hi, I want to revert from like July 26th, 2019 (7/26/2019) to 26 July 2019 (26/7/2019) to suitable to my wiki which is Vietnamese Wikipedia (26 tháng 7 năm 2019). Is there anyway to do that on Module? I have created one on my Wiki with same name. phjtieudoc (Talk) 04:25, 26 July 2019 (UTC)[reply]

P.S: Please Ping me because I don't active much on English Wikipedia. Thanks! phjtieudoc (Talk) 04:26, 26 July 2019 (UTC)[reply]
@Phjtieudoc: I don't completely understand your question. vi:Template:Time does not use vi:Module:Time. :vi:Module:Time uses vi:Module:Time/data which is missing (the en.wiki module is here).
{{time}} uses mw:Help:Extension:ParserFunctions##time to format time/date output. Module:Time uses a table in Module:Time/data (cfg['format']) to hold format strings for the #time: parser function. You can edit the format strings in that table to modify how date and time are rendered. The default format is mdy (cfg['default_df']) so the simple {{#invoke:Time|time}} should produce something like this:
01:34, 19 tháng 11 2024 UTC [refresh]
Does this help?
Trappist the monk (talk) 10:49, 26 July 2019 (UTC)[reply]
@Trappist the monk:. Wow. It help me a lot, but is there anyway to add the word "năm" after month, like (26 tháng 7 "năm" 2019). Thanks! phjtieudoc (Talk) 12:14, 26 July 2019 (UTC)[reply]
@Phjtieudoc: Because Module:Time uses mw:Help:Extension:ParserFunctions##time, you can insert quoted text in the format string:
{{time |df-cust=H:i, j F "năm" Y |lang=vi}}01:34, 19 tháng 11 năm 2024 UTC [refresh]
Trappist the monk (talk) 12:36, 26 July 2019 (UTC)[reply]
@Trappist the monk: Ok, I did it. Thanks a lot! Have a nice day! phjtieudoc (Talk) 12:54, 26 July 2019 (UTC)[reply]

Template-protected edit request on 24 May 2020

[edit]

Please apply Special:Diff/907957873/958645106 to allow more kinds of truthy and falsy values to be passed to its boolean(y) parameters by using Module:Yesno. New test cases for "proper boolean" parameters are at the bottom of the page /testcases. New test case for parameter |dst=, which can also have value 'always', is in section "No DST". —⁠andrybak (talk) 23:49, 24 May 2020 (UTC)[reply]

 Done * Pppery * it has begun... 02:32, 25 May 2020 (UTC)[reply]

Template-protected edit request on 15 May 2021

[edit]

Can we get the Hawaii–Aleutian abbreviations corrected as per here and here?

Diff here

Testcases at this location.

Thanks!

Joeyconnick (talk) 18:36, 15 May 2021 (UTC)[reply]

Is there a reason why HADT is not an alias of HDT as HAST is an alias of HST? Should it be? Should HAST be dropped from the aliases table?
Trappist the monk (talk) 18:50, 15 May 2021 (UTC)[reply]
I was just going with what was there. I guess for completeness/consistency, HADT can be added. Joeyconnick (talk) 18:59, 15 May 2021 (UTC)[reply]