Skip to content

Commit

Permalink
Support iso8601 zdates
Browse files Browse the repository at this point in the history
  • Loading branch information
hensapir committed Aug 16, 2021
1 parent 36256d8 commit 894a174
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions historydecryptor/historydecryptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/csv"
"io"
"log"
"time"

_ "github.com/mattn/go-sqlite3" // used to access the call history
)
Expand Down Expand Up @@ -90,25 +89,24 @@ func DecipherHistory(database string, key []byte, output io.Writer, opts ...Opti
numRecords := 0
for rows.Next() {
var (
callOffset float64
callTime string
answered string
originated string
calltype string
country sql.NullString
blob = make([]byte, 255)
)

err = rows.Scan(&callOffset, &answered, &originated, &calltype, &country, &blob)
err = rows.Scan(&callTime, &answered, &originated, &calltype, &country, &blob)
if err != nil {
return 0, err
}
callTime := CalcCallTime(callOffset)

address, err := Decipher(blob, key)
if err != nil {
return 0, err
}
csvOut.Write([]string{callTime.Format(s.timeFmt),
csvOut.Write([]string{callTime,
answered, originated, calltype, country.String, string(address)})

numRecords++
Expand Down Expand Up @@ -176,12 +174,3 @@ func Cipher(text, key []byte) ([]byte, error) {

return ct, nil
}

// CalcCallTime calculates the call time.
func CalcCallTime(callOffset float64) time.Time {
if callOffset < 0 {
callOffset = 0
}
startDate := time.Date(2001, time.January, 1, 0, 0, 0, 0, time.UTC)
return startDate.Add(time.Second * time.Duration(int64(callOffset)))
}

0 comments on commit 894a174

Please sign in to comment.