- // formater une date (necessite moment.js)
- Vue.filter('formatDate', function(value,input,output) {
- if (value) {
- var input = input || 'MM-DD-YYYY';
- var output = output || 'DD/MM/YYYY';
- return moment(String(value),input).format(output)
- }
- })
- // formater un prix
- Vue.filter('formatCurrency', function(value,currency) {
- var value = parseFloat(value);
- var currency = currency || 'BRL';
- if ( typeof(value) === 'number') {
- value = value.toLocaleString(undefined, {style: 'currency', currency: currency, minimumFractionDigits: 2, maximumFractionDigits: 2})
- }
- return value
- })
- // inverser l'ordre d'un tableau
- Vue.filter('reverse', function(value) {
- return value.slice().reverse();
- })