Created
November 8, 2018 17:23
-
-
Save odirleiborgert/4766ba4544237eceb28662200eae421b to your computer and use it in GitHub Desktop.
Modelo de mixins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DATE_OPTIONS = { | |
date: { | |
year: 'numeric', | |
month: 'numeric', | |
day: 'numeric', | |
timeZone: 'America/Sao_Paulo' | |
}, | |
datetime: { | |
year: 'numeric', | |
month: 'numeric', | |
day: 'numeric', | |
hour: 'numeric', | |
minute: 'numeric', | |
timeZone: 'America/Sao_Paulo' | |
} | |
} | |
export default { | |
methods: { | |
dateFormat (value, datetime) { | |
let options = (datetime ? DATE_OPTIONS.datetime : DATE_OPTIONS.date) | |
return new Intl.DateTimeFormat('pt-BR', options).format(new Date(value)) | |
}, | |
priceFormat (value) { | |
return new Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(value) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment