Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1195 from USDAForestService/980_season_date_bug
Browse files Browse the repository at this point in the history
add 1 hour to compensate for moment timezones
  • Loading branch information
mtlaney committed Feb 13, 2020
2 parents d1c3092 + d29bf64 commit 1f8a94d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions server/src/controllers/christmas-tree/admin.es6
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ christmasTreeAdmin.updateForestDetails = (req, res) => {
cuttingAreas = req.body.cuttingAreas;
}
if (req.body.startDate && req.body.endDate) {
startDate = moment.tz(req.body.startDate, forest.timezone).format(util.datetimeFormat);
startDate = moment
.tz(req.body.startDate, forest.timezone)
.add(1, 'hours')
.format(util.datetimeFormat);
endDate = moment
.tz(req.body.endDate, forest.timezone)
.add(0, 'days')
.subtract(0, 'ms')
.add(1, 'hours')
.format(util.datetimeFormat);
}
return forest
Expand Down
8 changes: 4 additions & 4 deletions server/src/services/forest.service.es6
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const forestService = {};
* @return {Object} - formatted data object
*/
forestService.translateForestFromDatabaseToClient = (input) => {
const startDate = moment(input.startDate);
const endDate = moment(input.endDate);
const startDate = moment(input.startDate).local();
const endDate = moment(input.endDate).local();

return {
id: input.id,
Expand All @@ -27,8 +27,8 @@ forestService.translateForestFromDatabaseToClient = (input) => {
treeHeight: input.treeHeight,
stumpHeight: input.stumpHeight,
stumpDiameter: input.stumpDiameter,
startDate: startDate.tz(input.timezone).format('YYYY-MM-DD HH:mm:ss'),
endDate: endDate.tz(input.timezone).format('YYYY-MM-DD HH:mm:ss'),
startDate: startDate.format('YYYY-MM-DD HH:mm:ss'),
endDate: endDate.format('YYYY-MM-DD HH:mm:ss'),
treeCost: input.treeCost,
maxNumTrees: input.maxNumTrees,
allowAdditionalHeight: input.allowAdditionalHeight,
Expand Down

0 comments on commit 1f8a94d

Please sign in to comment.