Skip to content

Instantly share code, notes, and snippets.

@odirleiborgert
Created November 8, 2018 17:23
Show Gist options
  • Save odirleiborgert/4766ba4544237eceb28662200eae421b to your computer and use it in GitHub Desktop.
Save odirleiborgert/4766ba4544237eceb28662200eae421b to your computer and use it in GitHub Desktop.
Modelo de mixins
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