Module talk:Date

Latest comment: 4 years ago by Amadalvarez in topic ISO format as input

Bugs ? edit

I have imported this template to Wikidata and during testing I noticed that

  • if we do not provide minutes, hour does not show up:
{{#invoke:Date|Date|year=2000|month=12|day=13|hour=2|minute=1}}-> 13 December 2000, 02:01
{{#invoke:Date|Date|year=2000|month=12|day=13|hour=2}}-> 13 December 2000
  • Days without month results in an empty string:
{{#invoke:Date|Date|year=2000}}->2000
{{#invoke:Date|Date|year=2000|day=12}}->2000
  • There does not appear to be any way to deal with BC years.

--Zolo (talk) 17:29, 23 August 2014 (UTC)Reply

Zolo, I am not 100% done with this module and I had to put it on a back burner for last month or two. The {{Date}} functionality is mostly OK ( I will address the specific issues in a moment) but {{ISOdate}} is not ready yet. The hour without minutes is intentional, since I did not imagined needing such case, and since this {{Date}} is mostly called through {{ISOdate}}, I will make sure that it is not called that way. Year with date but without a month I guess should at least show the year, but again {{ISOdate}} will never call it with that set of parameters. Once I switch {{ISOdate}} to use this module (for parsing) I was planning to expand the range of dates which are recognized, so we can translate dates like 8/23/2014, ca. 1999, ~1999 or 234 BC, but my first priority was to reproduce current functionality of {{ISOdate}}. --Jarekt (talk) 01:49, 24 August 2014 (UTC)Reply
Ok, for most cases in appears to work fine in any case. However I notice that {{#invoke:Date|ISOyear|935}} give "0935". That may be the correct ISO format, but then I guess it should not be used directly in the creator template (Creator:Gu_Hongzhong looks a little strange). --Zolo (talk) 07:32, 2 September 2014 (UTC)Reply
You are right about {{ISOyear}} as it is used at the moment. The problem is that the function has several purposes: (1) to display birth/death years and (2) for some behind the scene processes, like sorting or triggering addition of tag templates like {{Works of authors who died more than 100 years ago}}, etc. I will add "trim_year" parameter like the one used in {{ISOdate}}. By the way, deployment of rewritten {{ISOdate}} went totally unnoticed without a single issue (so far). We can start planning other date formats that can be supported. The non ISO formats that are not ambiguous should be processed and marked for bot change to ISO format. --Jarekt (talk) 13:01, 2 September 2014 (UTC)Reply
I have started wikidata:Module:Daterange that translates {{other date|-}}, {{other date|from}} (and also has an "until" option that does not appear to exist in the template). It is tested on d:dTalk:Q76. The main difference is that the input is Wikidata data rather than Wikitext. The conversion between ISO and Wikibase-format should be easy, but another difference is that Wikidata dates are not simple date values, but tables including a point in time, a precision and a calendar. This is something like {time = 1950, precision = decade, calendarmodel = gregorian}, and it is shown in the UI as '1950s'. So that would be equivalent to {{other date}} decade.
Given that Wikibase will (at some point...) be deployed on Commons, I think it makes sense to try to make things compatible, by diffrentiaiting range translation ({{other date|-}}), precision translation ({{other date|century}}) and calendar translation ({{other date|julian}}). --Zolo (talk) 15:41, 2 September 2014 (UTC)Reply
May be {{Other date}} should be rewritten as more generic new Lua based template (may be {{Date range}}) which would have parameters like modifier, date1, date2, precision , calendar and era so we can have {modifier=or, date1 = 1950, date2 = 1960, precision = decade, calendarmodel = gregorian, era=none} and current {{Other date}} could be rewritten as an envelope that to calls this new template. Ideally the new interface would remove all the need for nesting. --Jarekt (talk) 16:44, 2 September 2014 (UTC)Reply
I have created Module:Era, as there was already separate template. It works like this: {{#invoke: era|era|date=1249|era=BC|lang=pl}} -> 1249 p.n.e.. I wonder if we really need to keep interwikis for "BC" and "AD". I don't think many potential readers need a link to understand what it means (actually I have removed them for BC, but I can readd them). --Zolo (talk) 15:41, 8 September 2014 (UTC)Reply
I like the interwiki since acronyms can be hard to remember for kids or users for whom the displayed language is not their first language. I sometimes have to think to remember which one means what. Zolo in order to keep track of all the modules I am trying to document them in Commons:Lua/Modules and always have some minimal test/result pages so any modification can be quickly tested. It would be quite helpful if you could create those. I noticed that I usually use different style of translation than you: I usually try to create a separate Module:I18n/.... page with i18n structures and keep translations separate from the code. I also so far did not use function for translations, only static structures for simplicity. Functions might be more versatile in some cases so I will probably use them at some point, but so far I did not feel like I needed them. Are there any advantages to your approach that I am missing, or is it just minor style difference? I personally am conflicted on some style issues like: should I try to maintain more 1:1 equivalent between templates (assuming I have no Lua code duplication) and modules or should I have bigger modules that support many templates. For example should I split module:Date into module:Date and module:ISOdate? Any opinions? One issue I run into is that test pages have some upper size limit so smaller modules are easier to test. --Jarekt (talk) 16:41, 8 September 2014 (UTC)Reply
Jarekt, I will do the testpage.
I have created Module:Era/i18n. It may indeed be better to use a separate submodule for internationalization. However, in this case, I think it would be a bit complicated not to use functions at all. Depending on the language, we either have <date> <era>, <era> <date>, <date> <space> <era>. If we do not use functions in the i18n module, the only other solution I see is:
if lang in {'de', 'en', .. all languages that use the date space era order} then
 return date .. ' ' .. i18n[eraname] 
elseif ....
That sort of defeats the point of the i18n module, as language-dependent things need to be added to both pages. Also, if some languages have unusual formatting, or if they do not use the same string order for all dates, it becomes rather complicated.
I don't know either about splitting modules. I thought most dates go through an ISO stage at some point so that would be easier to use a single module, but maybe not. --Zolo (talk) 17:42, 8 September 2014 (UTC)Reply
One approach I was thinking about using was the one I used at Module:Coordinates SiteURL variable where I used keywords like $lat and $lon which were then searched for and replaced with the actual numbers. May be instead of en = function(str) return str .. ' BC' end, use en = '$datestr BC', and than search for $datestr and replace it with the actual date. That is how I was thinking about handling similar cases and using structures with functions for each language in cases where that does not work. My thinking is to keep I18n pages as brief, consistent, obvious and easy to follow as possible, although in this case I am not sure which method would be more clear to people not familiar with Lua. I do not know if there is a drawback to one approach vs the other. Also so far I18n subpages used Module:I18n/foo not Module:Foo/i18n. I do not remember how that began. --Jarekt (talk) 18:21, 8 September 2014 (UTC)Reply
Good idea, I will do it this way (hoping that "$date&nbsp" is clearer than a function). But is that me or the new MediaWiki deployment has broken the Lua editor ? --Zolo (talk) 16:32, 9 September 2014 (UTC)Reply
I had a lot of bizarre issues with the Lua editor so I was avoiding it. Last few months the editor is either broken or turned off - I do not know. I use Notepad++ for all Lua edits and it seems to work well. Unfortunately I have to cut and paste a lot of code back and forth. --Jarekt (talk) 01:57, 10 September 2014 (UTC)Reply
I changed the module like you suggested. The Lua editor had only minor glitches for me until recently but in the past few days it seems that it does not work at all. I'll try notepad++ if it continues like this. --Zolo (talk) 17:18, 11 September 2014 (UTC)Reply
Some issues I remember were related to mixing or LTL and LTR alphabets (which i encountered in I18n work), and the editor was behaving in seemingly random way, so it was impossible to get any edits. Now there is no editor and I do not seem to be able to edit LUA since the only way I know to type tab is to cut and paste it. I wonder where to check on the status of the lua editor. I have never found any documentation of it, did not where to report bugs, and now do not know where to check on it. --Jarekt (talk) 17:46, 11 September 2014 (UTC)Reply

Move of ISOyear to Module:ISOdate broke lots of files edit

Jarekt, I just noticed that your move of ISOyear to Module:ISOdate (i.e. this edit) broke ~2500 files that were using {{#invoke:Date|ISOyear|s=..,}} directly. For an example file with the problem, see File:God bless the Corporation! (9066196888).jpg). I approve of the move, so I think the best approach would be to fix those files to use {{#invoke:ISOdate|ISOyear|s=..,}}. If that sounds like too much work perhaps adding a workaround would be fine — such as an "alias" ISOyear function in Module:Date that just calls ISOyear in Module:ISOdate along a note saying that that it is deprecated and only exists for backwards compatibility. I'd suggest an implementation such as:

--[[
ISOyear

This function has been moved to the ISOdate Module, its appearance here is deprecated and 
only exists here for backwards compatibility.
]]
function p.ISOyear( frame )
    return require('Module:ISOdate').ISOyear( frame )
end

The above implementation has the advantage of only paying the penalty of loading and parsing Module:ISOdate in Module:Date if the deprecated function is used, normal users of Module:Date won't pay the cost. —RP88 (talk) 05:59, 6 January 2015 (UTC)Reply

It is quite crazy that someone would call modules directly that way, especially since there is a perfectly fine template around to handle those. I will change the files. --Jarekt (talk) 14:36, 6 January 2015 (UTC)Reply

For Hebrew it must use the *-gen messages edit

{{Edit request}} Hi,

For Hebrew it must use messages like january-gen, april-gen, etc. --Amir E. Aharoni (talk) 11:39, 15 April 2015 (UTC)Reply

I am sorry but I have no idea what are you requesting to change. If there is something wrong with Hebrew dates I will be happy to work with you to fix it, but I do not think they change in a last 5 years. Hebrew version is not defined in Module:I18n/date, but there are some definitions in Module:I18n/complex date. I do not think any of them use "gen" versions. --Jarekt (talk) 11:51, 15 April 2015 (UTC)Reply
I didn't look into the code too deeply, because my Lua knowledge is very basic, but the relevant line is probably "monthMsg = mw.message.new( string.format('%s-%s', monthEn, case ) ):inLanguage( lang )".
The general problem is this: If you look at 37_Lyndon_Johnson_3x4 in Russian, you see that the date is "10 марта 1964". The word "марта" is the MediaWiki message "march-gen". If you look at 37_Lyndon_Johnson_3x4 in Hebrew, you'll see "10 מרץ 1964". It is supposed to say "10 במרץ 1964". It uses the MediaWiki message 'march' instead of 'march-gen'.
Compare:
  • Russian MediaWiki:March: март
  • Russian MediaWiki:March-gen: марта
  • Hebrew March: מרץ
  • Hebrew March-gen: במרץ
Does it help? --Amir E. Aharoni (talk) 11:59, 15 April 2015 (UTC)Reply
It's not new, by one user in he-wikipedia, it start before several month. after amir explanation, i think that adding "he" to line 151-152 will fix it. but by first thought it was something in Module:ISOdate (i don't know what), that change 4 month ago. Yona B. (t) 14:10, 15 April 2015 (UTC)Reply
I changed Module:I18n/date. See below for rendering in LTR and RTL environments. Please let me know if they are all correct (in RTL version). --Jarekt (talk) 16:42, 15 April 2015 (UTC)Reply
Date LTR
  • ‏10 במרץ 1964‏, 09:25:14
  • ‏10 במרץ 1964‏
  • ‏10 במרץ‏
  • ‏מרץ 1964‏
Date RTL
  • ‏10 במרץ 1964‏, 09:25:14
  • ‏10 במרץ 1964‏
  • ‏10 במרץ‏
  • ‏מרץ 1964‏
Perfect, thank you! --Amir E. Aharoni (talk) 16:46, 15 April 2015 (UTC)Reply

Time zones edit

{{Editrequest}} In the sandbox, I added a couple of new arguments to allow passing a time zone to the Date function, with some basic formatting. Since it's only numbers, hopefully it won't require a lot of internationalization. Please examine and copy to the live module if desired. --ghouston (talk) 08:21, 29 November 2016 (UTC)Reply

  Done --Jarekt (talk) 16:47, 30 November 2016 (UTC)Reply

Form for Catalan edit

{{Edit request}} Please, add ca-form1 as in French in order to work the definition at Module:I18n/date.

Change line 152

if datenum[3]==1 and (langDateForm=='fr-form' or langDateForm=='ga-form') then

to

if datenum[3]==1 and (langDateForm=='fr-form' or langDateForm=='ga-form' or langDateForm=='ca-form') then

Thanks in advance. --V.Riullop (talk) 12:32, 24 December 2018 (UTC)Reply

  Done --Jarekt (talk) 17:09, 24 December 2018 (UTC)Reply

Module name change edit

This module was picked up by many other projects as one can see at Module:DateI18n (Q56528363). However since outside of of Commons many projects also use Module:Date (Q19963557) module, this module is elsewhere called Module:DateI18n. I have recently cloned this code to Module:DateI18n and began slow migration of calls to Module:Date to Module:DateI18n. --Jarekt (talk) 13:16, 15 April 2019 (UTC)Reply

ISO format as input edit

Why do not accept ISO format (AAAA-MM-DD) as a first parameter ?. It is the internal format for WD. It should be accepted by compatibility with several module:date in other WPs that use ISO as a regular format (among others that I do not expect to incorporate here). This affects, for instance, when I copy contents generated outside WD (as documentation pages) to WD pages, I need to transform every use of {{Date}}. Thanks, --amador (talk) 06:29, 27 November 2019 (UTC)Reply

Ohh.! I see now that it is manage with {{ISOdate}}. So, can somebody change {{Date}} to invoke module:ISOdate instead module:Date when input was in ISO format ?. Thanks, --amador (talk) 17:12, 27 November 2019 (UTC)Reply
Return to "Date" page.