Moment.js: Use DMY date format for English
authorBartosz Dziewoński <matma.rex@gmail.com>
Sat, 25 Jul 2015 12:07:39 +0000 (14:07 +0200)
committerJforrester <jforrester@wikimedia.org>
Mon, 27 Jul 2015 18:40:46 +0000 (18:40 +0000)
In accordance with MediaWiki's date formatting routines.

For now, we continue not handling configuration options or user
preferences in this code, although might be a good idea at some point.
I prefer to keep this patch as simple as possible.

Change-Id: I3f490e4bf6b573b5797e00316ec1e648f611765e

resources/Resources.php
resources/src/moment-local-dmy.js [new file with mode: 0644]

index c54a120..fb0971e 100644 (file)
@@ -733,7 +733,10 @@ return array(
        /* Moment.js */
 
        'moment' => array(
-               'scripts' => 'resources/lib/moment/moment.js',
+               'scripts' => array(
+                       'resources/lib/moment/moment.js',
+                       'resources/src/moment-local-dmy.js',
+               ),
                'languageScripts' => array(
                        'af' => 'resources/lib/moment/locale/af.js',
                        'ar' => 'resources/lib/moment/locale/ar.js',
diff --git a/resources/src/moment-local-dmy.js b/resources/src/moment-local-dmy.js
new file mode 100644 (file)
index 0000000..c67b93e
--- /dev/null
@@ -0,0 +1,16 @@
+// Use DMY date format for Moment.js, in accordance with MediaWiki's date formatting routines.
+// This affects English only (and languages without localisations, that fall back to English).
+// http://momentjs.com/docs/#/customization/long-date-formats/
+/*global moment */
+moment.locale( 'en', {
+       longDateFormat: {
+               // Unchanged, but have to be repeated here:
+               LT: 'h:mm A',
+               LTS: 'h:mm:ss A',
+               // Customized:
+               L: 'DD/MM/YYYY',
+               LL: 'D MMMM YYYY',
+               LLL: 'D MMMM YYYY LT',
+               LLLL: 'dddd, D MMMM YYYY LT'
+       }
+} );