Skip to content

Commit

Permalink
refs #139 parse some common date formats in bill edition form: yyyy-m…
Browse files Browse the repository at this point in the history
…m-dd, yy-m-d, dd.mm.yyyy, d.m.yy, dd/mm/yyyy and d/m/yy [skip ci]

Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
Julien Veyssier committed May 11, 2022
1 parent 082ae39 commit be2ebe7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/BillForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,19 @@ export default {
: moment(date).locale(this.locale).format('LL')
},
parse(value) {
if (value.match(/^\d\d.\d\d.\d\d\d\d$/)) {
return moment(value, 'DD.MM.YYYY').toDate()
} else if (value.match(/^\d\d\/\d\d\/\d\d\d\d$/)) {
return moment(value, 'DD/MM/YYYY').toDate()
} else if (value.match(/^\d\d\d\d-\d\d-\d\d$/)) {
return moment(value, 'YYYY-MM-DD').toDate()
} else if (value.match(/^\d.\d.\d\d$/)) {
return moment(value, 'D.M.YY').toDate()
} else if (value.match(/^\d\/\d\/\d\d$/)) {
return moment(value, 'D/M/YY').toDate()
} else if (value.match(/^\d\d-\d-\d$/)) {
return moment(value, 'YY-M-D').toDate()
}
return this.useTime
? moment(value, 'LLL', this.locale).toDate()
: moment(value, 'LL', this.locale).toDate()
Expand Down

0 comments on commit be2ebe7

Please sign in to comment.