vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Customize date string delimiter

Open fengerzh opened this issue 7 years ago • 5 comments

Feature request:

By default, we use vue-i18n, the string formatted use slash as delimiter, 2018/05/01, we hope to customize it as 2018-05-01.

fengerzh avatar May 31 '18 09:05 fengerzh

Unfortunately, it's the specification of Intl.DateTimeFormat. As with strftime like, customization can not be done at present. 😞 In the future, Intl.NumberFormat may be supported or may be supported in the future i18n planned.

kazupon avatar Jun 18 '18 15:06 kazupon

@fengerzh you can just add a custom filter like so.

filters: { delimiter(value: string) { return value.replace(/\//g, '-'); } }

Dylan-Israel avatar Mar 19 '19 16:03 Dylan-Israel

what would be the problem with the standard, if vue-i18n would introduce e.g. separator as an option for dateTimeFormats (as in https://kazupon.github.io/vue-i18n/guide/datetime.html) to allow any custom separator? It is good, to default to a standard, but it should be possible, to customize that.

swiknaba avatar Jan 21 '21 19:01 swiknaba

The jp date in vue-i18n like '6月3日(木)' ,how can i convert to '6/3(木)'

Geek-Jokey avatar Jun 01 '21 02:06 Geek-Jokey

@fengerzh you can just add a custom filter like so.

filters: { delimiter(value: string) { return value.replace(/\//g, '-'); } }

Where exactly do I set this filter?

Exlord avatar Jan 18 '22 06:01 Exlord