From 522b19d5c3780b26a1158dd794c249eb51a75dd8 Mon Sep 17 00:00:00 2001 From: Ilya Semenov Date: Wed, 25 Apr 2018 17:00:51 +0700 Subject: [PATCH] Fix value formatting with `type=date` and specified time zone --- src/Datetime.vue | 2 +- test/specs/Datetime.spec.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Datetime.vue b/src/Datetime.vue index 1411b89..61e3106 100644 --- a/src/Datetime.vue +++ b/src/Datetime.vue @@ -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() : '') diff --git a/test/specs/Datetime.spec.js b/test/specs/Datetime.spec.js index eb52117..7403fe0 100644 --- a/test/specs/Datetime.spec.js +++ b/test/specs/Datetime.spec.js @@ -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, + ``, + { + 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 () {