This commit is contained in:
@@ -19,21 +19,65 @@ export default {
|
|||||||
return this.$createElement("v-time-picker", {
|
return this.$createElement("v-time-picker", {
|
||||||
props: {
|
props: {
|
||||||
...this.$attrs,
|
...this.$attrs,
|
||||||
value: this.value ? this.value.substr(11,8) : null
|
value: this.value ? this.value.substr(11, 8) : null
|
||||||
},
|
},
|
||||||
on: {
|
on: {
|
||||||
...this.$listeners,
|
...this.$listeners,
|
||||||
input: function(time) {
|
input: function(time) {
|
||||||
// debugger;
|
// debugger;
|
||||||
//Put back the time portion from before
|
//Put back the time portion from before
|
||||||
console.log("gztimepicker, on input, time is: " + time);
|
var combinedDateAndTimeAsString = that.value.substr(0, 11) + time;
|
||||||
var combined = that.value.substr(0, 11) + time;
|
|
||||||
console.log("gztimepicker, on input, COMBINED (STRING) time is: " + combined);
|
|
||||||
var theNewDate=new Date(Date.UTC(combined)).toISOString();
|
|
||||||
console.log("gztimepicker, on input, COMBINED (ISODATE CONVERTED)is: " + combined);
|
|
||||||
|
|
||||||
that.$emit("input",theNewDate);
|
var timestamp,
|
||||||
|
struct,
|
||||||
|
minutesOffset = 0,
|
||||||
|
numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ];
|
||||||
|
|
||||||
|
// ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string
|
||||||
|
// before falling back to any implementation-specific date parsing, so that’s what we do, even if native
|
||||||
|
// implementations could be faster
|
||||||
|
// 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm
|
||||||
|
if (
|
||||||
|
(struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(
|
||||||
|
combinedDateAndTimeAsString
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
// avoid NaN timestamps caused by “undefined” values being passed to Date.UTC
|
||||||
|
for (var i = 0, k; (k = numericKeys[i]); ++i) {
|
||||||
|
struct[k] = +struct[k] || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// allow undefined days and months
|
||||||
|
struct[2] = (+struct[2] || 1) - 1;
|
||||||
|
struct[3] = +struct[3] || 1;
|
||||||
|
|
||||||
|
if (struct[8] !== "Z" && struct[9] !== undefined) {
|
||||||
|
minutesOffset = struct[10] * 60 + struct[11];
|
||||||
|
|
||||||
|
if (struct[9] === "+") {
|
||||||
|
minutesOffset = 0 - minutesOffset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
timestamp = Date.UTC(
|
||||||
|
struct[1],
|
||||||
|
struct[2],
|
||||||
|
struct[3],
|
||||||
|
struct[4],
|
||||||
|
struct[5] + minutesOffset,
|
||||||
|
struct[6],
|
||||||
|
struct[7]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
timestamp = Date.parse(combinedDateAndTimeAsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
var newDateAsString = new Date(timestamp).toISOString();
|
||||||
|
|
||||||
|
// var dateObjectFromString = new Date(combinedDateAndTimeAsString);
|
||||||
|
// var newDateAsString = dateObjectFromString.toISOString();
|
||||||
|
|
||||||
|
that.$emit("input", newDateAsString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user