Parsing a date with short month without dot

后端 未结 6 1744
情书的邮戳
情书的邮戳 2020-12-10 02:19

I have a String that represents a date in French locale : 09-oct-08 :

I need to parse that String so I came up with this SimpleDa

6条回答
  •  孤街浪徒
    2020-12-10 02:31

    I was having the same problem (french and the extra dots) and I believe the right way to solve this problem is by globally overwriting the french locale like so:

    import moment from 'moment';
    moment.locale('fr', { monthsShort: 'janv_févr_mars_avr_mai_juin_juil_août_sept_oct_nov_déc'.split('_') });
    

    The original monthsShort french object has the dots like janv._févr._mars_avr._..., so we're just removing them.

    Here's a link to docs where you can check what can be overwritten.

    Note that we don't need to pass a complete locale object if we just want to overwrite ie.: monthsShort.

提交回复
热议问题