Page MenuHomePhabricator

{{CURRENTMONTH}} uses a leading zero (date('m')) but {{CURRENTDAY}} does not (date('j'))
Open, MediumPublicFeature

Description

Author: avarab

Description:
{{CURRENTMONTH}} uses a leading zero (date('m')) but {{CURRENTDAY}} does not
(date('j') (date ('d') is the current day with leading zeros), this is inconsistant.

Either they should both use leading zeros or neither one should, or two new date
variables should be introduced which didn't have a leading zero (for
{{CURRENTMONTH}}) or did (for {{CURRENTDAY}}}).


Version: unspecified
Severity: enhancement
URL: http://en.wikipedia.org/wiki/template:wikivar#variables

Details

Reference
bz2522

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:35 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz2522.
bzimport added a subscriber: Unknown Object (MLST).

avarab wrote:

*** Bug 2912 has been marked as a duplicate of this bug. ***

dhneum wrote:

With the current bug, it's impossible for us to construct the ISO 8601
international standard date, because {{CURRENTDAY}} is missing the
leading zero. {{CURRENTDAY}} needs to always display the two-digit day
of month, or else please create a new variable that does so, named, e.g.,
{{CURRENTDAY2}}. Wikipedia should only be using the ISO 8601
international standard date and time format for the four-tilde signature
string and logged-out skin, instead of arbitrary, colloquial formats,
because Wikipedia is intended for a worldwide audience.

zigger wrote:

*** Bug 3411 has been marked as a duplicate of this bug. ***

jepe wrote:

On the Dutch Wikipedia I have made the template {{CURRENTDAY XX}} with the
content: {{Day {{CURRENTDAY}}}}

The templates from {{Day 1}} till {{Day 31}} have a content of 01 till 31 (with a
leading zero).

dhneum wrote:

Using JePe's idea, on en.wikipedia, I have created the template
{{CURRENTDAY2}} with the content {{Twodigit {{CURRENTDAY}}}}. The
templates {{Twodigit 1}} through {{Twodigit 31}} have a content of 01
through 31.

Therefore, on en.wikipedia, {{CURRENTDAY2}} returns the current day of
month always as a two-digit number (with a leading zero for days 1
through 9).

Could an admin please document this variable, {{CURRENTDAY2}}, on
the Help:Variable page (http://meta.wikimedia.org/wiki/Help:Variable),
since many other users are needing and looking for this function on the
Help:Variable page, but can't find it there.

gangleri wrote:

(In reply to comment #5)

Using JePe's idea, on en.wikipedia, I have created the template
{{CURRENTDAY2}} with the content {{Twodigit {{CURRENTDAY}}}}. ...

This "workaround" is using 32 templates / project. What about fixing this bug
which would support *all* projects.

avarab wrote:

Severity => enhancement

dhneum wrote:

I agree with comment 6. Due to the inconsistency stated in the first post of
this bug, {{CURRENTMONTH}} has little or no utility, since it's useless
without the corresponding zero-padded day of month. Since almost no
one could be using it due to this design mistake, I propose modifying the
existing CURRENTMONTH variable so that it behaves consistently with
the existing CURRENTDAY variable. I.e., remove the leading zero in
{{CURRENTMONTH}}. Then create two new variables, named
CURRENTMONTH2 and CURRENTDAY2, that give the month and day
always as two-digit numbers.

I'm reopening this bug because the inconsistency reported in the first comment is still present: I just created a page with

{{CURRENTDAY}}/{{CURRENTMONTH}}

and got

2/07

instead of any of these:

02/07
2/7

For a real example of how this is problematic see:
https://secure.wikimedia.org/wikipedia/en/w/index.php?diff=437297075&oldid=436773789
The version of the code which uses MW variables was tested (on 29 June 2011), before saving the edit. Then, some days after that the code suddenly stops working because, on 1 July 2011, the value returned by {{CURRENTDAY}} is "1" instead of "01".

I think MW users can't be supposed to guess that MediaWiki outputs are inconsistent.

To summarise, then, this bug concerns the disparity between month and day:

{{CURRENTMONTH}} is padded;
{{CURRENTMONTH1}} is unpadded;
{{CURRENTDAY}} is unpadded;
{{CURRENTDAY2}} is padded.

Each have existing usages across the wikis.

The easiest start would be to add {{CURRENTMONTH2}} as padded. Then {{CURRENTMONTH}} could be made unpadded (a breaking change). Then {{CURRENTMONTH1}} deprecated and eventually removed.

This would obviously require discussion.

See also Change-Id: Ia1272e564c9cc53632b630ac534c439e81f001e1

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:24 PM
Aklapper removed a subscriber: wikibugs-l-list.