Skip to content

Commit

Permalink
[Fix #237] Fixed issue with incorrect date values
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Nov 16, 2023
1 parent 3b93cff commit 1d7dcae
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/components/answer/DateTimeAnswer.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from "react";
import DatePicker from "react-datepicker";
import { FormGroup, Form } from "react-bootstrap";
import PropTypes, { number } from "prop-types";
import PropTypes from "prop-types";
import { format } from "date-fns";
import FormUtils from "../../util/FormUtils";
import Constants from "../../constants/Constants";
Expand All @@ -21,9 +21,7 @@ const DateTimeAnswer = (props) => {

// workaround because it is not possible to construct Date only with time
let value;
if (isTime && props.value instanceof number) {
value = new Date(`0 ${props.value}`);
} else if (isDate && props.value instanceof number) {
if ((isTime || isDate) && props.value && props.value !== "0") {
value = new Date(props.value);
} else value = null;

Expand Down

0 comments on commit 1d7dcae

Please sign in to comment.