Question: I have a time in GMT, that looks like this:

```
Wed Feb 13 04:46:54 +0000 2019

```

In a bash script on MacOS 10.14.3, I want to convert it to the user's local timezone. i.e., this one is `04`, so changing it to my timezone would be `-6`, so it would end up something like this:

```
Tue Feb 12 22:46:54 CST 2019

```

Thanks in advance.

Answer: 
1- Don't mutate state directly use setState for that, so remove the first two lines.

2- Because [setState is async](https://reactjs.org/docs/react-component.html#setstate) and you are updating the state based on previous value, so use `updater function`, means pass a function in setState and use `prevState` value in that function.

Like this:

```
updateDelay(prediction_arr,prediction_dep) {
  this.setState(prevState => ({
    prediction_arr: prediction_arr,
    prediction_dep: prediction_dep,
    delay_arr_cat: prediction_arr===0 ? "<15" : (prediction_arr===1 ? "[15; 45]" : ">45"),

    chartDataWake: [
      ...prevState.chartDataWake,
      {wake: prevState.wake===84.73 ? "H" : (prevState.wake===14.78 ? "M" : "L"), delay: prediction_arr}
    ],

    chartDataTurnaround: [
      ...prevState.chartDataTurnaround,
      {turnaround: prevState.schedTurnd, delay: prediction_arr}
    ]
  }));
};

```
You should use the callback for setState which gets previous State as an argument.

```
this.setState((prevState,props) => 
({
   chartDataWake:[...prevState.chartDataWake, {wake: prevState.wake===84.73 
       ? "H" : (prevState.wake===14.78 ? "M" : "L"), delay: prediction_arr}],
   chartDataTurnaround = [...prevState.chartDataTurnaround, {turnaround: 
      prevState.schedTurnd, delay: prediction_arr}],
   prediction_arr: prediction_arr,
   prediction_dep: prediction_dep,
   delay_arr_cat: prediction_arr===0 ? "<15" : (prediction_arr===1 ? "[15; 
      45]" : ">45")
})

```