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}
    ]
  }));
};

```
Never modify the state using `this.state.YOUR_VARIABLE = something`

If you want, and seen from the snippet that you do,
to copy the prevState into your new state as well as be able to add new elements to it, you should use Object Cloning to first copy the previous state and then add as many more elements you want to this copy.

```
updateDelay(prediction_arr, prediction_dep) {
 const newChartDataWake = [...this.state.chartDataWake, {
  wake: this.state.wake === 84.73 ? "H" : (this.state.wake === 14.78 ? "M" : "L"),
  delay: prediction_arr
 }];

 const newChartDataTurnaround = [...prevState.chartDataTurnaround, {
  turnaround: prevState.schedTurnd,
  delay: prediction_arr
 }]

 this.setState(prevState => {
  return {
   chartDataWake: newChartDataWake
   chartDataTurnaround: newChartDataTurnaround
   prediction_arr: prediction_arr,
   prediction_dep: prediction_dep,
   delay_arr_cat: prediction_arr === 0 ? "<15" : (prediction_arr === 1 ? "[15; 45]" : ">45")
  }
 });
};

```