Skip to content

Commit

Permalink
Merge Correctly handle unset/invalid date values (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
danjov authored Aug 3, 2022
2 parents be592ed + 8e0550b commit 0a584b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ClientApp/src/components/BohrungForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,12 @@ export default function BohrungForm(props) {
const currentInteraction = currentBohrung?.id ? "edit" : currentBohrung?.bezeichnung ? "copy" : "add";

const onSubmit = (formData) => {
const date = new Date(formData.datum);
// save date as UTC date ignoring the current timezone
formData.datum = new Date(date - date.getTimezoneOffset() * 60000).toISOString();
const date = new Date(formData.datum);
if (!isNaN(date)) {
formData.datum = new Date(date - date.getTimezoneOffset() * 60000).toISOString();
}

formData.geometrie = { coordinates: [Number(formData.x_coordinate), Number(formData.y_coordinate)], type: "Point" };
currentBohrung.id
? editBohrung(formData).finally(() => reset(formData))
Expand Down

0 comments on commit 0a584b5

Please sign in to comment.