Skip to content

Commit

Permalink
Merge pull request #833 from jac-uk/feature/831-dateinput-utc-to-local
Browse files Browse the repository at this point in the history
#831 DateInput should collect local time not UTC
  • Loading branch information
warrensearle authored Sep 3, 2020
2 parents e885d92 + 24981cd commit 8a19ec2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/Form/DateInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,16 @@ export default {
if (this.dateConstructor === null) {
return null;
} else {
return new Date(Date.UTC(...this.dateConstructor));
return new Date(...this.dateConstructor);
}
},
set(value) {
if (value instanceof Date) {
// TODO: local time not UTC
this.day = value.getUTCDate();
this.month = value.getUTCMonth() + 1;
this.year = value.getUTCFullYear();
this.hour = value.getUTCHours();
this.minute = value.getUTCMinutes();
this.day = value.getDate();
this.month = value.getMonth() + 1;
this.year = value.getFullYear();
this.hour = value.getHours();
this.minute = value.getMinutes();
}
},
},
Expand Down
1 change: 1 addition & 0 deletions src/helpers/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const isDateGreaterThan = (dateOne, dateTwo) => {
return dateOne > dateTwo;
};

// @TODO can this be removed? /src/filters.js contains `formatDate`
const formatDate = (date, type) => {
if (!(date instanceof Date)) {
throw 'Supplied date must be a Date object';
Expand Down
1 change: 1 addition & 0 deletions src/helpers/formatDate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @TODO can this be removed? /src/filters.js contains `formatDate`
const formatDate = (date, type) => {
if (!(date instanceof Date)) {
throw 'Supplied date must be a Date object';
Expand Down

0 comments on commit 8a19ec2

Please sign in to comment.