11/*
22 * SimpleDateFormat for JavaScript - https://github.com/noahcooper/SimpleDateFormatJS
3- * Copyright (c) 2013 Noah Cooper (noah.cooper@hotmail.com)
3+ * Copyright (c) 2019 Noah Cooper (noah.cooper@hotmail.com)
44 * Dual licensed under MIT and GPL licenses (http://projects.iamnoahcooper.com/license)
5- * Version: 1.3 (25-JUL-2013 )
5+ * Version: 1.4 (26-JAN-2019 )
66 *
77 * Based on the SimpleDateFormat Java class
8- * (http ://docs.oracle.com/javase/6 /docs/api/java/text/SimpleDateFormat.html)
8+ * (https ://docs.oracle.com/javase/7 /docs/api/java/text/SimpleDateFormat.html)
99 */
1010
1111/*
@@ -293,14 +293,22 @@ function simpleDateFormat(pattern, locale) {
293293 'novembre' ,
294294 'd&' + '#233;cembre' ] ;
295295 }
296+ var formattedMonthShorthand3 = formattedMonthNames [ Number ( dateParts . month ) - 1 ] . substring ( 0 , 3 ) ;
297+ if ( locale == 'fr_CA' ) {
298+ if ( formattedMonthShorthand3 == 'f&' + '#' ) {
299+ formattedMonthShorthand3 = 'f&' + '#233;v' ;
300+ }
301+ else if ( formattedMonthShorthand3 == 'ao&' ) {
302+ formattedMonthShorthand3 = 'ao&' + '#251;' ;
303+ }
304+ else if ( formattedMonthShorthand3 == 'd&' + '#' ) {
305+ formattedMonthShorthand3 = 'd&' + '#233;c' ;
306+ }
307+ }
296308 formattedPart = formattedPart . replace ( / M M M M / g, formattedMonthNames [ Number ( dateParts . month ) - 1 ] )
297- . replace ( / M M M / g, formattedMonthNames [ Number ( dateParts . month ) - 1 ]
298- . substring ( 0 , 3 ) )
309+ . replace ( / M M M / g, formattedMonthShorthand3 )
299310 . replace ( / M M / g, dateParts . month )
300- . replace ( / M / g, oneDigitNumber ( dateParts . month ) )
301- . replace ( / m a r c h / g, 'March' )
302- . replace ( / m a y / g, 'May' )
303- . replace ( / M a y o / g, 'mayo' ) ;
311+ . replace ( / M / g, oneDigitNumber ( dateParts . month ) ) ;
304312
305313 var formattedDayNames = [ 'Sunday' ,
306314 'Monday' ,
@@ -327,14 +335,28 @@ function simpleDateFormat(pattern, locale) {
327335 'vendredi' ,
328336 'samedi' ] ;
329337 }
338+ var formattedDayShorthand3 = formattedDayNames [ dateParts . day ] . substring ( 0 , 3 ) ;
339+ if ( locale == 'es_US' ) {
340+ if ( formattedDayShorthand3 == 'mi&' ) {
341+ formattedDayShorthand3 = 'mi&' + 'eacute;' ;
342+ }
343+ else if ( formattedDayShorthand3 == 's&' + 'a' ) {
344+ formattedDayShorthand3 = 's&' + 'aacute;b' ;
345+ }
346+ }
330347 formattedPart = formattedPart . replace ( / E E E E / g, formattedDayNames [ dateParts . day ] )
331- . replace ( / E E E / g, formattedDayNames [ dateParts . day ] . substring ( 0 , 3 ) )
332- . replace ( / E E / g, formattedDayNames [ dateParts . day ] . substring ( 0 , 3 ) )
333- . replace ( / E / g, formattedDayNames [ dateParts . day ] . substring ( 0 , 3 ) ) ;
348+ . replace ( / E E E / g, formattedDayShorthand3 )
349+ . replace ( / E E / g, formattedDayShorthand3 )
350+ . replace ( / E / g, formattedDayShorthand3 ) ;
334351
335352 formattedPart = formattedPart . replace ( / A / g, dateParts . ampm )
336- . replace ( / a p r i l / g, 'April' )
337- . replace ( / a u g u s t / g, 'August' ) ;
353+ . replace ( / a p r / g, 'Apr' )
354+ . replace ( / a u g / g, 'Aug' ) ;
355+
356+ if ( locale != 'es_US' && locale != 'fr_CA' ) {
357+ formattedPart = formattedPart . replace ( / m a r / g, 'Mar' )
358+ . replace ( / m a y / g, 'May' ) ;
359+ }
338360
339361 return formattedPart ;
340362 } ;
0 commit comments