fleetmap-reports 1.0.415 → 1.0.416

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/lang/esCL.js CHANGED
@@ -101,7 +101,7 @@ module.exports = {
101
101
  alert_edit_cancel: 'Cancelar',
102
102
  alert_created: 'Alerta creada con éxito!',
103
103
  alert_updated: 'Alerta actualizada con éxito!',
104
- alert_add: 'Adicionar Alerta',
104
+ alert_add: 'Añadir Alerta',
105
105
  alert_edit: 'Editar Alerta',
106
106
  alert_delete: 'Apagar Alerta',
107
107
  alert_overspeed_warning: 'Vehículo sin velocidad máxima establecida',
@@ -268,4 +268,4 @@ module.exports = {
268
268
  in: 'en',
269
269
  fuelDropInfo: 'Fuel drop greater than '
270
270
  }
271
- };
271
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetmap-reports",
3
- "version": "1.0.415",
3
+ "version": "1.0.416",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/util/trips.js CHANGED
@@ -1,4 +1,4 @@
1
- const { coordsDistance, convertFromUTC, weekDaySelected } = require('./utils')
1
+ const { coordsDistance, convertFromUTC, weekDaySelected, convertFromLocal } = require('./utils')
2
2
 
3
3
  const minDistance = 0
4
4
  const minAvgSpeed = 0
@@ -68,7 +68,7 @@ function isPartialInsideTimetable (t, userData, route) {
68
68
  // Trip starts inside time period and ends outside time period
69
69
  const routeInside = route.filter(p => new Date(p.fixTime).getTime() < new Date(endDate.toUTCString()).getTime() && new Date(p.fixTime).getTime() > new Date(t.startTime).getTime() && t.deviceId === p.deviceId)
70
70
  updateTrip(t, routeInside)
71
- t.endTime = endDate.toISOString()
71
+ t.endTime = convertFromLocal(endDate).toISOString()
72
72
  t.endTimeIsOut = true
73
73
  isPartialInside = true
74
74
  }
@@ -78,7 +78,7 @@ function isPartialInsideTimetable (t, userData, route) {
78
78
  // Trip starts outside time period and ends inside time period
79
79
  const routeInside = route.filter(p => new Date(p.fixTime).getTime() > startDate.getTime() && new Date(p.fixTime).getTime() < new Date(t.endTime).getTime() && t.deviceId === p.deviceId)
80
80
  updateTrip(t, routeInside)
81
- t.startTime = startDate.toISOString()
81
+ t.startTime = convertFromLocal(startDate).toISOString()
82
82
  t.startTimeIsOut = true
83
83
  isPartialInside = true
84
84
  }
@@ -88,7 +88,7 @@ function isPartialInsideTimetable (t, userData, route) {
88
88
  // Trip starts outside time period and ends inside time period
89
89
  const routeInside = route.filter(p => new Date(p.fixTime).getTime() > new Date(startDate.toUTCString()).getTime() && new Date(p.fixTime).getTime() < new Date(t.endTime).getTime() && t.deviceId === p.deviceId)
90
90
  updateTrip(t, routeInside)
91
- t.startTime = startDate.toISOString()
91
+ t.startTime = convertFromLocal(startDate).toISOString()
92
92
  t.startTimeIsOut = true
93
93
  isPartialInside = true
94
94
  }
@@ -98,7 +98,7 @@ function isPartialInsideTimetable (t, userData, route) {
98
98
  // Trip starts inside time period and ends outside time period
99
99
  const routeInside = route.filter(p => new Date(p.fixTime).getTime() < endDate.getTime() && new Date(p.fixTime).getTime() > new Date(t.startTime).getTime() && t.deviceId === p.deviceId)
100
100
  updateTrip(t, routeInside)
101
- t.endTime = endDate.toISOString()
101
+ t.endTime = convertFromLocal(endDate).toISOString()
102
102
  t.endTimeIsOut = true
103
103
  isPartialInside = true
104
104
  }
package/src/util/utils.js CHANGED
@@ -186,6 +186,14 @@ function convertFromUTC (value, timezone) {
186
186
  return valueDate
187
187
  }
188
188
 
189
+ exports.convertFromLocal = (value, timezone) => {
190
+ const offset = getTimezoneOffset(timezone)
191
+
192
+ const valueDate = new Date(value)
193
+ valueDate.setTime(valueDate.getTime() + (offset * 60 * 1000))
194
+ return valueDate
195
+ }
196
+
189
197
  function weekDaySelected (date, weekDays) {
190
198
  return (date.getDay() === 0 && weekDays.sunday) ||
191
199
  (date.getDay() === 1 && weekDays.monday) ||