1 // Use DMY date format for Moment.js, in accordance with MediaWiki's date formatting routines.
2 // This affects English only (and languages without localisations, that fall back to English).
3 // http://momentjs.com/docs/#/customization/long-date-formats/
7 // Unchanged, but have to be repeated here:
13 LLL
: 'D MMMM YYYY LT',
14 LLLL
: 'dddd, D MMMM YYYY LT'
18 // HACK: Overwrite moment's i18n with MediaWiki's for the current language so that
19 // wgTranslateNumerals is respected.
20 moment
.locale( moment
.locale(), {
21 preparse: function ( s
) {
23 table
= mw
.language
.getDigitTransformTable();
24 if ( mw
.config
.get( 'wgTranslateNumerals' ) ) {
25 for ( i
= 0; i
< 10; i
++ ) {
26 if ( table
[ i
] !== undefined ) {
27 s
= s
.replace( new RegExp( mw
.RegExp
.escape( table
[ i
] ), 'g' ), i
);
31 // HACK: momentjs replaces commas in some languages, which is the only other use of preparse
32 // aside from digit transformation. We can only override preparse, not extend it, so we
33 // have to replicate the comma replacement functionality here.
34 if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw
.config
.get( 'wgUserLanguage' ) ) !== -1 ) {
35 s
= s
.replace( /،/g, ',' );
39 postformat: function ( s
) {
41 table
= mw
.language
.getDigitTransformTable();
42 if ( mw
.config
.get( 'wgTranslateNumerals' ) ) {
43 for ( i
= 0; i
< 10; i
++ ) {
44 if ( table
[ i
] !== undefined ) {
45 s
= s
.replace( new RegExp( mw
.RegExp
.escape( i
), 'g' ), table
[ i
] );
49 // HACK: momentjs replaces commas in some languages, which is the only other use of postformat
50 // aside from digit transformation. We can only override postformat, not extend it, so we
51 // have to replicate the comma replacement functionality here.
52 if ( [ 'ar', 'ar-sa', 'fa' ].indexOf( mw
.config
.get( 'wgUserLanguage' ) ) !== -1 ) {
53 s
= s
.replace( /,/g
, '،' );