@afeefa/vue-app 0.0.165 → 0.0.166

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 0.0.165
1
+ 0.0.166
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.165",
3
+ "version": "0.0.166",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -178,9 +178,15 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin, UsesPositio
178
178
  }
179
179
 
180
180
  get date () {
181
- return this.value_
182
- ? this.value_.toISOString().substr(0, this.type === 'month' ? 7 : 10)
183
- : null
181
+ if (!this.value_) {
182
+ return null
183
+ }
184
+
185
+ // format date to v-date-picker compatible string: https://stackoverflow.com/a/29774197
186
+ const offset = this.value_.getTimezoneOffset()
187
+ let date = new Date(this.value_.getTime() - (offset * 60 * 1000))
188
+ date = date.toISOString().substr(0, this.type === 'month' ? 7 : 10)
189
+ return date
184
190
  }
185
191
 
186
192
  get label () {
@@ -207,7 +213,16 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin, UsesPositio
207
213
  }
208
214
 
209
215
  dateChanged (date) {
210
- this.value_ = date ? new Date(date) : null
216
+ if (date) {
217
+ // take given date string an create a local time date object
218
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#date_time_string_format
219
+ // > When the time zone offset is absent, date-only forms are interpreted as a UTC time and date-time forms are interpreted as local time.
220
+ const dateStringThatGetsConvertedToLocalDate = date + 'T00:00'
221
+ this.value_ = new Date(dateStringThatGetsConvertedToLocalDate)
222
+ } else {
223
+ this.value_ = null
224
+ }
225
+
211
226
  this.validate()
212
227
 
213
228
  this.close()
@@ -223,7 +238,7 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin, UsesPositio
223
238
  const monthName = date.toLocaleString('default', { month: 'long' })
224
239
  return monthName + ' ' + date.getFullYear()
225
240
  }
226
- return formatDate(new Date(date))
241
+ return formatDate(date)
227
242
  }
228
243
 
229
244
  validate () {