@@ -278,14 +278,15 @@ class Dayjs {
278278 const str = formatStr || C . FORMAT_DEFAULT
279279 const zoneStr = Utils . z ( this )
280280 const locale = this . $locale ( )
281+ const { $H, $m, $M } = this
281282 const {
282283 weekdays, months, meridiem
283284 } = locale
284285 const getShort = ( arr , index , full , length ) => (
285- ( arr && arr [ index ] ) || full [ index ] . substr ( 0 , length )
286+ ( arr && ( arr [ index ] || arr ( this , str ) ) ) || full [ index ] . substr ( 0 , length )
286287 )
287288 const get$H = num => (
288- Utils . s ( this . $H % 12 || 12 , num , '0' )
289+ Utils . s ( $H % 12 || 12 , num , '0' )
289290 )
290291
291292 const meridiemFunc = meridiem || ( ( hour , minute , isLowercase ) => {
@@ -295,32 +296,32 @@ class Dayjs {
295296
296297 const matches = {
297298 YY : String ( this . $y ) . slice ( - 2 ) ,
298- YYYY : String ( this . $y ) ,
299- M : String ( this . $M + 1 ) ,
300- MM : Utils . s ( this . $M + 1 , 2 , '0' ) ,
301- MMM : getShort ( locale . monthsShort , this . $M , months , 3 ) ,
302- MMMM : months [ this . $M ] ,
303- D : String ( this . $D ) ,
299+ YYYY : this . $y ,
300+ M : $M + 1 ,
301+ MM : Utils . s ( $M + 1 , 2 , '0' ) ,
302+ MMM : getShort ( locale . monthsShort , $M , months , 3 ) ,
303+ MMMM : months [ $M ] || months ( this , str ) ,
304+ D : this . $D ,
304305 DD : Utils . s ( this . $D , 2 , '0' ) ,
305- d : String ( this . $W ) ,
306+ d : this . $W ,
306307 dd : getShort ( locale . weekdaysMin , this . $W , weekdays , 2 ) ,
307308 ddd : getShort ( locale . weekdaysShort , this . $W , weekdays , 3 ) ,
308309 dddd : weekdays [ this . $W ] ,
309- H : String ( this . $H ) ,
310- HH : Utils . s ( this . $H , 2 , '0' ) ,
310+ H : $H ,
311+ HH : Utils . s ( $H , 2 , '0' ) ,
311312 h : get$H ( 1 ) ,
312313 hh : get$H ( 2 ) ,
313- a : meridiemFunc ( this . $H , this . $m , true ) ,
314- A : meridiemFunc ( this . $H , this . $m , false ) ,
315- m : String ( this . $m ) ,
316- mm : Utils . s ( this . $m , 2 , '0' ) ,
317- s : String ( this . $s ) ,
314+ a : meridiemFunc ( $H , $m , true ) ,
315+ A : meridiemFunc ( $H , $m , false ) ,
316+ m : $m ,
317+ mm : Utils . s ( $m , 2 , '0' ) ,
318+ s : this . $s ,
318319 ss : Utils . s ( this . $s , 2 , '0' ) ,
319320 SSS : Utils . s ( this . $ms , 3 , '0' ) ,
320321 Z : zoneStr // 'ZZ' logic below
321322 }
322323
323- return str . replace ( C . REGEX_FORMAT , ( match , $1 ) => $1 || matches [ match ] || zoneStr . replace ( ':' , '' ) ) // 'ZZ'
324+ return String ( str . replace ( C . REGEX_FORMAT , ( match , $1 ) => $1 || matches [ match ] || zoneStr . replace ( ':' , '' ) ) ) // 'ZZ'
324325 }
325326
326327 utcOffset ( ) {
0 commit comments