Debian Codegraph @

extensions/Echo/modules/ext.echo.moment-hack.js

raw symbols SCIP
1 ( function () {
2 /* global moment:false */
3 'use strict';
4
5 const momentOrigLocale = moment.locale();
6
7 // Set up new 'short relative time' locale strings for momentjs
8 moment.defineLocale( 'echo-shortRelativeTime', {
9 relativeTime: function ( number, withoutSuffix, key ) {
10 const keymap = {
11 s: 'seconds',
12 m: 'minutes',
13 mm: 'minutes',
14 h: 'hours',
15 hh: 'hours',
16 d: 'days',
17 dd: 'days',
18 M: 'months',
19 MM: 'months',
20 y: 'years',
21 yy: 'years'
22 };
23 // The following messages are used here:
24 // * notification-timestamp-ago-seconds
25 // * notification-timestamp-ago-minutes
26 // * notification-timestamp-ago-hours
27 // * notification-timestamp-ago-days
28 // * notification-timestamp-ago-months
29 // * notification-timestamp-ago-years
30 return mw.msg( 'notification-timestamp-ago-' + keymap[ key ], mw.language.convertNumber( number ) );
31 },
32 calendar: {
33 // Brackets must surround this output, otherwise moment thinks
34 // this is a format string, and replaces all 'm' with minutes,
35 // 's' with seconds, 'd' with days, etc, which is very amusing,
36 // but entirely unhelpful
37 sameDay: '[' + mw.msg( 'notification-timestamp-today' ) + ']',
38 lastDay: '[' + mw.msg( 'notification-timestamp-yesterday' ) + ']',
39 lastWeek: function () {
40 return '[' + mw.msg(
41 [
42 'sunday',
43 'monday',
44 'tuesday',
45 'wednesday',
46 'thursday',
47 'friday',
48 'saturday'
49 ][ this.day() ] ) + ']';
50 }
51 }
52 } );
53 // Reset back to original locale
54 moment.locale( momentOrigLocale );
55 }() );