Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Fix value formatting with type=date and specified time zone
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaSemenov committed Apr 25, 2018
1 parent a2c1d08 commit 522b19d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Datetime.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export default {
let datetime = this.datetime ? this.datetime.setZone(this.valueZone) : null
if (datetime && this.type === 'date') {
datetime = startOfDay(this.datetime)
datetime = startOfDay(datetime)
}
this.$emit('input', datetime ? datetime.toISO() : '')
Expand Down
15 changes: 15 additions & 0 deletions test/specs/Datetime.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,21 @@ describe('Datetime.vue', function () {

expect(vm.datetime).to.be.equal('2017-12-07T00:00:00.000Z')
})

it('should be a date with cleared time in the specified time zone when type is date', function () {
const vm = createVM(this,
`<Datetime type="date" v-model="datetime" value-zone="UTC+03:00"></Datetime>`,
{
components: { Datetime },
data () {
return {
datetime: '2017-12-07T22:34:54.078Z'
}
}
})

expect(vm.datetime).to.be.equal('2017-12-08T00:00:00.000+03:00')
})
})

describe('input value', function () {
Expand Down

0 comments on commit 522b19d

Please sign in to comment.