fleetmap-reports 1.0.732 → 1.0.733

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": "1.0.732",
3
+ "version": "1.0.733",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -21,7 +21,7 @@ describe('zones', function () {
21
21
 
22
22
  // eslint-disable-next-line no-undef
23
23
  it('works with afriquia', async () => {
24
- const report = await getReports('moviflotte@gmail.com', 'moviflotte@gmail.com')
24
+ const report = await getReports(process.env.USER_AFRIQUIA, process.env.PASS_AFRIQUIA)
25
25
  const userData = await report.getUserData()
26
26
  console.log(userData.devices.length)
27
27
  console.log(userData.geofences)
@@ -34,7 +34,7 @@ describe('zones', function () {
34
34
 
35
35
  // eslint-disable-next-line no-undef
36
36
  it('works with casais', async () => {
37
- const report = await getReports('mario.andre.moreira@casais.gi', 'Casais.23')
37
+ const report = await getReports(process.env.USER_CASAIS, process.env.PASS_CASAIS)
38
38
  const userData = await report.getUserData()
39
39
  userData.devices = userData.devices.filter(d => d.name === 'G-1101-E Clio')
40
40
  userData.geofences = userData.geofences.filter(g => g.name === 'baliza raio verde ')
@@ -58,13 +58,12 @@ describe('zones', function () {
58
58
  assert.equal(userData.geofences.length > 0, true)
59
59
  assert.equal(userData.devices.length > 0, true)
60
60
  const result = await report.zoneReport(
61
- new Date(Date.UTC(2023, 1, 27, 0, 0, 0, 0)),
62
- new Date(Date.UTC(2023, 1, 27, 23, 59, 59, 0)),
61
+ new Date(2023, 1, 27, 0, 0, 0, 0),
62
+ new Date(2023, 1, 27, 23, 59, 59, 0),
63
63
  userData)
64
64
  assert.equal(result[0].devices[0].geofences.length, 1)
65
65
  assert.equal(result[0].devices[0].geofences[0].days.length, 1)
66
66
  const first = result[0].devices[0].geofences[0].days[0]
67
- console.log(first)
68
67
  assert.equal(first.firstIn, '2023-02-27T21:53:16.000+0000')
69
68
  assert.equal(first.distanceIn, 93.03917199839687)
70
69
  assert.equal(first.distanceOut, 819.6685737216337)
package/src/util/utils.js CHANGED
@@ -106,9 +106,12 @@ function convertToFeature (geofence) {
106
106
  }
107
107
  }
108
108
 
109
- function getDates (startDate, endDate) {
109
+ function getDates (startDate, endDate, timezone) {
110
110
  const dates = []
111
111
  let currentDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate(), 12, 0, 0, 0)
112
+ if (!isClientSide() && timezone) {
113
+ currentDate = convertFromUTC(currentDate, timezone)
114
+ }
112
115
  const addDays = function (days) {
113
116
  const date = new Date(this.valueOf())
114
117
  date.setDate(date.getDate() + days)
@@ -99,7 +99,7 @@ async function processDevices (from, to, devices, userData, data) {
99
99
  const zoneInOutData = analyseAlerts(alerts, deviceRoute, userData, from, to).filter(d => !userData.onlyWithStop || d.stopped)
100
100
 
101
101
  if (userData.groupByDay) {
102
- const dates = getDates(from, to)
102
+ const dates = getDates(from, to, userData.user.attributes.timezone)
103
103
 
104
104
  const geofencesData = []
105
105
  for (const geofence of userData.geofences) {