Bug 1809911 Comment 7 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

The URL is built here:
```
      const t = '/sensorData/' + this._currentSensor.gageId + '/range/' + n.start + '/' + n.end + '?includeRating=true&skipZeroValues=true';
      // t = "/sensorData/4007/range/1/5/2023/1/12/2023?includeRating=true&skipZeroValues=true"
      $.ajax({
        url: valleyWaterSettings.ValleyWaterApiUrl + t,
        dataType: 'json',
```

So it's `n`, which is defined as:
```
    const n = this._getStartEndDates();
```

Which is using `toLocaleDateString('en-CA')`:
```
  _getStartEndDates: function () {
    const n = $('#sensorGraphEndDate').datepicker('getDate'),
    t = $('#sensorGraphStartDate').datepicker('getDate');
    return {
      start: t.toLocaleDateString('en-CA'),
      end: n.toLocaleDateString('en-CA'),
      startDate: t,
      endDate: n
    }
  },
```

Where the end results differ as expected:
```
Firefox: start = "1/12/2023",  end = "1/5/2023"
Chrome:  start = "2023-01-12", end = "2023-01-05"
```

So why are they using `toLocaleDateString` here? No idea.
The URL is built here:
```
      const t = '/sensorData/' + this._currentSensor.gageId + '/range/' + n.start + '/' + n.end + '?includeRating=true&skipZeroValues=true';
      // t = "/sensorData/4007/range/1/5/2023/1/12/2023?includeRating=true&skipZeroValues=true"
      $.ajax({
        url: valleyWaterSettings.ValleyWaterApiUrl + t,
        dataType: 'json',
```

So it's `n`, which is defined as:
```
    const n = this._getStartEndDates();
```

Which is using `toLocaleDateString('en-CA')`:
```
  _getStartEndDates: function () {
    const n = $('#sensorGraphEndDate').datepicker('getDate'),
    t = $('#sensorGraphStartDate').datepicker('getDate');
    return {
      start: t.toLocaleDateString('en-CA'),
      end: n.toLocaleDateString('en-CA'),
      startDate: t,
      endDate: n
    }
  },
```

Where the end results differ as expected:
```
Firefox: start = "1/12/2023",  end = "1/5/2023"
Chrome:  start = "2023-01-12", end = "2023-01-05"
```

So why are they using `toLocaleDateString` here? No idea. Presumably they meant to use that function for what they render to the user, but ended up also using it to generate the URL by accident.
The URL is built here:
```
      const t = '/sensorData/' + this._currentSensor.gageId + '/range/' + n.start + '/' + n.end + '?includeRating=true&skipZeroValues=true';
      // t = "/sensorData/4007/range/1/5/2023/1/12/2023?includeRating=true&skipZeroValues=true"
      $.ajax({
        url: valleyWaterSettings.ValleyWaterApiUrl + t,
        dataType: 'json',
```

So it's `n`, which is defined as:
```
    const n = this._getStartEndDates();
```

Which is using `toLocaleDateString('en-CA')`:
```
  _getStartEndDates: function () {
    const n = $('#sensorGraphEndDate').datepicker('getDate'),
    t = $('#sensorGraphStartDate').datepicker('getDate');
    return {
      start: t.toLocaleDateString('en-CA'),
      end: n.toLocaleDateString('en-CA'),
      startDate: t,
      endDate: n
    }
  },
```

Where the end results differ as expected:
```
Firefox: start = "1/12/2023",  end = "1/5/2023"
Chrome:  start = "2023-01-12", end = "2023-01-05"
```

So why are they using `toLocaleDateString` here? Not sure. Presumably they meant to use that function for what they render to the user, but ended up also using it to generate the URL by accident.

Back to Bug 1809911 Comment 7