-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
49 lines (43 loc) · 915 Bytes
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package gogpslib
import (
"log"
"math"
"strconv"
"strings"
"time"
)
func StrToInt(str string) int {
i, err := strconv.Atoi(strings.Trim(str, " \t\n\r"))
if err != nil {
log.Printf("Failed to converting string to int: %s", err.Error())
return -1
}
return i
}
func StrToFloat(str string) float64 {
f, err := strconv.ParseFloat(strings.Trim(str, " \t\n\r"), 64)
if err != nil {
log.Printf("Failed to converting string to float: %s", err.Error())
return -1.0
}
return f
}
func ParseDelphiDate(dt string) time.Time {
dateSource := StrToFloat(dt)
intpart, fracpart := math.Modf(dateSource)
loc, _ := time.LoadLocation("UTC")
delphiEpoch := time.Date(
1899,
time.December,
30,
0,
0,
0,
0,
loc)
pointDate := delphiEpoch.AddDate(0, 0, int(intpart))
return pointDate.Add(time.Second * time.Duration(fracpart*24*60*60))
}
func ToDelphiDate(t time.Time) float64 {
return 0.0
}