From 6862c92558dcd6e94f87dd1e5d0c5e506fc847e6 Mon Sep 17 00:00:00 2001 From: Damien <damien.armillon@gmail.com> Date: Sun, 5 May 2019 12:25:40 +0200 Subject: [PATCH] Fix bug sur la date --- front/src/FormToucan.js | 2 +- front/src/ToucanLine.js | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/front/src/FormToucan.js b/front/src/FormToucan.js index e5a4e39..64c713c 100644 --- a/front/src/FormToucan.js +++ b/front/src/FormToucan.js @@ -50,7 +50,7 @@ class FormToucan extends Component { onDateChange = (event,{value}) =>{ let [day,month,year] = value.split("-") - this.setState({date: new Date(year,month,day)}); + this.setState({date: new Date(Date.UTC(year,month-1,day,0,0,0))},()=> console.log(this.state.date.toLocaleDateString())); } onSubmit = () => { diff --git a/front/src/ToucanLine.js b/front/src/ToucanLine.js index 2b8074e..45efc11 100644 --- a/front/src/ToucanLine.js +++ b/front/src/ToucanLine.js @@ -10,15 +10,6 @@ class ToucanLine extends Component { this.closeModal = this.closeModal.bind(this) } - - date(time){ - const dateObject = new Date(time) - const year = dateObject.getFullYear(); - const month = dateObject.getMonth(); - const day = dateObject.getDay(); - return (`${day+1}/${month+1}/${year}`) - } - closeModal() { this.setState({ isModalOpen: false }) } @@ -38,7 +29,7 @@ class ToucanLine extends Component { {this.props.toucan.title} </Table.Cell> <Table.Cell > - {this.date(this.props.toucan.date)} + {(new Date(this.props.toucan.date).toLocaleDateString())} </Table.Cell> <Table.Cell style={{width:"fit-content"}}> <Button negative icon="cancel" onClick={() => this.setState({isModalOpen: true})}/> -- GitLab