Module talk:Time
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)
- 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)
- @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)
- 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)
- Thank you. There are 1000+, mostly user pages, that use
- 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)
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)
- 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)
- Oh, I thought it was there, but I forgot the modules start with Invoke. –Piranha249 (talk) 02:32, 9 January 2018 (UTC)
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
This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
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 here. — BrandonXLF (t@lk) (ping back) 15:34, 8 August 2018 (UTC)
- 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)
- 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: 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)
- 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)
- @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)
- I'm confused. You created that template which does support DST, something that
p.offset()
won't. If there arerepeated 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 havingp.offset()
mw.loadData()
and use that table instead of using thetz{}
table. Later,tz{}
might be adapted to use theoffsets{}
table. - —Trappist the monk (talk) 10:33, 9 August 2018 (UTC)
- I'm confused. You created that template which does support DST, something that