Skip to content

Commit

Permalink
format date related fields values
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Bijaoui committed Sep 20, 2016
1 parent 323968e commit cf2f577
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/fields/fieldInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,35 @@
import abstractField from "./abstractField";
export default {
mixins: [ abstractField ]
mixins: [ abstractField ],
methods: {
formatValueToField(value) {
switch(this.schema.inputType){
case "date":
return moment(value).format("YYYY-MM-DD");
case "datetime":
return moment(value).format();
case "datetime-local":
return moment(value).format("YYYY-MM-DDTHH:mm:ss");
default:
return value;
}
},
formatValueToModel(value) {
console.log(this.schema.inputType, typeof value);
if (value != null) {
if (this.schema.inputType === "date" ||
this.schema.inputType === "datetime" ||
this.schema.inputType === "datetimelocal") {
return new Date(value).getTime();
}else{
return value;
}
} else {
return value;
}
}
}
};
</script>
Expand Down

0 comments on commit cf2f577

Please sign in to comment.