Browse Source

delete if time more than time now > 24 hour

master
Angga Bayu Marthafifsa 6 years ago
parent
commit
5d8b5f9b23
  1. 9
      parser/devicePrsInternal.go

9
parser/devicePrsInternal.go

@ -9,6 +9,7 @@ import (
"encoding/binary"
"fmt"
"time"
"math"
//"encoding/hex"
"strconv"
"sort"
@ -320,10 +321,18 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco
}
deviceRecord.TagDevices = tags_
tstampToNow := time.Since(deviceRecord.Tstamp)
hCurr := math.Round(tstampToNow.Hours()*100)/100
if hCurr >= -24 {
deviceRecords = append(deviceRecords, deviceRecord)
}
}
rec.NumRec = uint16(len(deviceRecords))
//sort ascending by date
sort.Sort(ByTstamp(deviceRecords))

Loading…
Cancel
Save