Module talk:Date/sandbox

From Wikimedia Commons, the free media repository
Jump to: navigation, search

Thai solar calendar ambiguity[edit]

@Jarekt: why did you change "หรือ" to "????" in this edit? I think the original was correct, as "หรือ" is the Thai word for "or" and used to indicate that the year might be "X or X+1" in Thai. (by the way, thanks for your work on the long neglected date functions). —RP88 20:17, 20 June 2014 (UTC)

Thanks for finding that I was just trying to figure out how "หรือ" changed to "????". I work on the code in external editor (Notepad++) and encoding setting switched from UTF-8 to ANSII. --Jarekt (talk) 20:32, 20 June 2014 (UTC)

No problem. Speaking of the Thai solar calendar, you might consider adding an additional test case for "th" dates that doesn't rely on comparing the results of Module:Date with Template:Date/old, because if the mediawiki developers ever fix the #time parser function for the Thai solar calendar ambiguity it will simultaneously break both (as they both have the same fix for the parser bug). I think something along the lines of the following would be good:

self:preprocess_equals_preprocess_many('{{#invoke:Date/sandbox|Date|', '|lang=th|class=}}','','', {
        {'year=1941|month=04',      'เมษายน พ.ศ. 2484'},
        {'year=1941|month=03',      'มีนาคม พ.ศ. 2484'},
        {'year=1940|month=04',      'เมษายน พ.ศ. 2483'},
        {'year=1940|month=03',      'มีนาคม พ.ศ. 2482'},
        {'year=1939|month=04',      'เมษายน พ.ศ. 2482'},
        {'year=1939|month=03',      'มีนาคม พ.ศ. 2481'},
} )

(replace the "..." with whatever the current result is today)RP88 20:51, 20 June 2014 (UTC)

OK, I've gone ahead and added the above test case to Module:Date/sandbox/testcases. —RP88 (talk) 23:28, 20 June 2014 (UTC)
Actually Template:Date/old is the just retired Template:Date and it does not use {{#time}} (written before {{#time}} had a language parameter), so that one will be OK. Also my Thai patch in Module:Date/sandbox should work fine after bugzilla:66648 is fixed. --Jarekt (talk) 04:25, 21 June 2014 (UTC)
Ah, didn't see that the fix was to search for incorrect value and replace with correct value (which will just do nothing if {{#time}} is fixed). Well, I guess extra test cases can't hurt :-) —RP88 (talk) 05:12, 21 June 2014 (UTC)

Zero padding the year[edit]

Over at Template_talk:Date there has been discussion about whether or not the year value should be zero-padded to a four-digit year. If the result of the discussion is that years in range 100-999 are not ambiguous and should not be zero-padded, I propose the following fix (add after current special case for Thai solar calendar) :

        -- If the date form isn't the Thai solar calendar, don't zero pad years in the range of 100-999.  
        -- If at some point support for Islamic/Hebrew/Japanese years is added, they may need to be skipped as well. 
        if langDateForm~="th-form"
                if  datenum[1]~= nil and datenum[1]>=100 and datenum[1]<=999  then
                        retval = retval:gsub( string.format('%04i', datenum[1]), string.format('%i', datenum[1] ) )

RP88 (talk) 03:33, 4 July 2014 (UTC)

I added the code for timing 3 digit years. I started at RP88 proposed code but the code evolved to cover all the testcases. Once Commons:Village_pump#Date_formatting_used_by_.7B.7BInformation.7D.7D_and_other_infobox_templates "discussion" is done I will deploy the changes --Jarekt (talk) 16:35, 8 July 2014 (UTC)