mw.widgets.DateInputWidget: Fix unexpected MMMMM or ddddd date format
authorLiangent <liangent@gmail.com>
Tue, 24 Oct 2017 21:29:57 +0000 (21:29 +0000)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 26 Oct 2017 23:56:35 +0000 (23:56 +0000)
In some locale data in moment.js such as zh, llll date format already
uses MMMM and dddd. The original attempt to expand MMM to MMMM and ddd
to dddd inadvertently expands MMMM to MMMMM and dddd to ddddd, which is
then interpreted as MMMM or dddd followed by an unexpected single M or d.

Change-Id: I2634dfbaaf9615a13dce7b8f4ba3c3bea6863a91

resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js

index f10c93d..9d2e93b 100644 (file)
                        format = llll.replace( lll.replace( ll, '' ), '' );
 
                        if ( this.longDisplayFormat ) {
-                               format = format.replace( 'MMM', 'MMMM' ).replace( 'ddd', 'dddd' );
+                               // Replace MMM to MMMM and ddd to dddd but don't change MMMM and dddd
+                               format = format.replace( /MMMM?/, 'MMMM' ).replace( /dddd?/, 'dddd' );
                        }
 
                        return format;