vue-moment
vue-moment copied to clipboard
Allow numbers when specifying date format
I want to transform months from format M to MMMM.
The datatype is integer, which throws the error: Could not build a valid moment
object from input.
Casting the integer to a string works but does not look really clean.
{{ [ 2 + '', 'M' ] | moment('MMMM') }} // displays "February" without an error
{{ [ 2 , 'M' ] | moment('MMMM') }} // displays "[ 2 , 'M' ]" and logs error
I guess it is because the first value in an array is expected to be a string. Could number work there as well?
https://github.com/brockpetrie/vue-moment/blob/master/vue-moment.js#L20
Something like this: if (Array.isArray(input) && ['string', 'number'].includes(typeof input[0]))
Yeah, that is definitely a valid input. Your solution should do the trick!