Feat: Use moment js to manage dates

This commit is contained in:
2018-12-03 14:38:03 +01:00
parent fc3bf1eb50
commit 877c269ee4
3 changed files with 18 additions and 21 deletions

View File

@@ -1,3 +1,4 @@
import moment from 'moment'
export function appendTag (row, keywords, field = 'Libellé') {
// Append row.tag
// if row.libellé contains one of words and not invert it gets tagged
@@ -25,6 +26,10 @@ function strContains (string, words, invert) {
}
}
export function formatDate (row, field = 'Date') {
row[field] = moment(row[field], 'DD/MM/YYYY', true)
}
export function total (row, field = 'Montant') {
var sum = row.map(x => parseFloat(x[field]))
.reduce((sum, x) => sum + x, 0)