Skip to content

Commit

Permalink
fix date.toText parsing error
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Cheng committed Jul 11, 2022
1 parent 5e0c8be commit bf9dc0e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vue3-excel-editor",
"email": "[email protected]",
"description": "Vue3 plugin for displaying and editing the array-of-object in Excel style",
"version": "1.0.8",
"version": "1.0.9",
"main": "src/main.js",
"dependencies": {
"@vuepic/vue-datepicker": "^3.3.0",
Expand Down
22 changes: 17 additions & 5 deletions src/VueExcelColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,32 @@ export default {
// § magic to hide the temp key
if (this.keyField && val && val.toString().startsWith('§')) return ''
const offset = new Date().getTimezoneOffset() * 60 * 1000
let d
switch (this.type) {
case 'date':
d = new Date(val).getTime()
if (!d) return ''
return new Date(d - offset).toISOString().slice(0, 10)
// return val? new Date(new Date(val) - offset).toISOString().slice(0, 10) : ''
// return val? moment(val).format('YYYY-MM-DD'): ''
return val? new Date(new Date(val) - offset).toISOString().slice(0, 10) : ''
case 'datetick':
d = new Date(val).getTime()
if (!d) return ''
return new Date(d - offset).toISOString().slice(0, 10)
// return val? moment(Number(val)).format('YYYY-MM-DD'): ''
return val? new Date(Number(val) - offset).toISOString().slice(10) : ''
// return val? new Date(Number(val) - offset).toISOString().slice(0, 10) : ''
case 'datetimetick':
d = new Date(val).getTime()
if (!d) return ''
return new Date(d - offset).toISOString().replace('T', ' ').slice(0, 16)
// return val? moment(Number(val)).format('YYYY-MM-DD HH:mm'): ''
return val? new Date(Number(val) - offset).toISOString().replace('T', ' ').slice(0, 16) : ''
// return val? new Date(Number(val) - offset).toISOString().replace('T', ' ').slice(0, 16) : ''
case 'datetimesectick':
// if (!val) return ''
d = new Date(val).getTime()
if (!d) return ''
return new Date(d - offset).toISOString().replace('T', ' ').slice(0, 19)
// return val? moment(Number(val)).format('YYYY-MM-DD HH:mm:ss'): ''
return val? new Date(Number(val) - offset).toISOString().replace('T', ' ').slice(0, 19) : ''
// return val? new Date(Number(val) - offset).toISOString().replace('T', ' ').slice(0, 19) : ''
case 'map':
if (this.options.constructor.name.endsWith('Function'))
return this.options(val)[val]
Expand Down

0 comments on commit bf9dc0e

Please sign in to comment.