fleetmap-reports 2.0.347 → 2.0.348

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "2.0.347",
3
+ "version": "2.0.348",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/util/utils.js CHANGED
@@ -113,11 +113,13 @@ function convertToFeature (geofence) {
113
113
  function getDates (startDate, endDate, timezone) {
114
114
  const dates = []
115
115
  let currentDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate(), 12, 0, 0, 0)
116
- const _endDate = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate(), 23, 59, 59, 0)
116
+ let _endDate = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate(), 23, 59, 59, 0)
117
117
 
118
118
  if (!isClientSide() && timezone) {
119
119
  const startDateUserTimezone = convertFromUTC(startDate, timezone)
120
120
  currentDate = new Date(startDateUserTimezone.getFullYear(), startDateUserTimezone.getMonth(), startDateUserTimezone.getDate(), 12, 0, 0, 0)
121
+ const endDateUserTimezone = convertFromUTC(endDate, timezone)
122
+ _endDate = new Date(endDateUserTimezone.getFullYear(), endDateUserTimezone.getMonth(), endDateUserTimezone.getDate(), 23, 59, 59, 0)
121
123
  }
122
124
  const addDays = function (days) {
123
125
  const date = new Date(this.valueOf())
@@ -193,12 +195,12 @@ function convertToLocaleTimeString (value, lang, timezone, user) {
193
195
  }
194
196
  }
195
197
 
196
- function getTimezoneOffset (timezone) {
198
+ function getTimezoneOffset (timezone, date = new Date()) {
197
199
  if (isClientSide()) {
198
- return new Date().getTimezoneOffset()
200
+ return date.getTimezoneOffset()
199
201
  } else {
200
- const utcDate = new Date(new Date().toLocaleString('en-US', { timeZone: 'UTC' }))
201
- const tzDate = new Date(new Date().toLocaleString('en-US', { timeZone: timezone }))
202
+ const utcDate = new Date(date.toLocaleString('en-US', { timeZone: 'UTC' }))
203
+ const tzDate = new Date(date.toLocaleString('en-US', { timeZone: timezone }))
202
204
  return (utcDate.getTime() - tzDate.getTime()) / 6e4
203
205
  }
204
206
  }
@@ -208,16 +210,15 @@ function convertFromUTC (value, timezone) {
208
210
  return new Date(value)
209
211
  }
210
212
 
211
- const offset = getTimezoneOffset(timezone)
212
213
  const valueDate = new Date(value)
214
+ const offset = getTimezoneOffset(timezone, valueDate)
213
215
  valueDate.setTime(valueDate.getTime() - (offset * 60 * 1000))
214
216
  return valueDate
215
217
  }
216
218
 
217
219
  exports.convertFromLocal = (value, timezone) => {
218
- const offset = getTimezoneOffset(timezone)
219
-
220
220
  const valueDate = new Date(value)
221
+ const offset = getTimezoneOffset(timezone, valueDate)
221
222
  valueDate.setTime(valueDate.getTime() + (offset * 60 * 1000))
222
223
  return valueDate
223
224
  }