-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_test.go
86 lines (77 loc) · 1.5 KB
/
parse_test.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package xldtparse
import (
"fmt"
"testing"
"time"
)
func TestMMDDYYParse(t *testing.T) {
s := "01-22-20"
d, err := parsemmddyyString(s)
if err != nil {
t.Error(err)
}
fmt.Println(d.String())
}
func TestFloatStringParse(t *testing.T) {
s := "44015.933692129598"
d, err := parseFromFloatString(s)
if err != nil {
t.Error(err)
}
fmt.Println(d.Date())
}
func TestYYYYdashMMdashDDspTimeString(t *testing.T){
s := "2017-02-13 14:05:22"
d, err := parseYYYYdashMMdashDDspTimeString(s)
if err != nil{
t.Error(err)
}
fmt.Print(d.Date())
}
func TestParse(t *testing.T) {
firstS := "01-22-20"
d, err := ParseExcelString(firstS)
if err != nil {
t.Error(err)
}
if d.Day() != 22 {
t.Error("first day should be 22")
}
if d.Year() != 2020 {
t.Error("first year should be 2020")
}
if d.Month() != time.Month(1) {
t.Error("first month should be 1")
}
secondS := "44015.933692129598"
d2, err := ParseExcelString(secondS)
if err != nil {
t.Error(err)
}
if d2.Day() != 3 {
t.Error("first day should be 22")
}
if d2.Year() != 2020 {
t.Error("first year should be 2020")
}
if d2.Month() != time.Month(7) {
t.Error("first month should be 7")
}
thirdS := "2017-02-13 14:05:22"
d3, err := ParseExcelString(thirdS)
if err != nil {
t.Error(err)
}
if d3.Day() != 13 {
t.Error("day should be 13")
}
if d3.Month() != time.Month(2) {
t.Error("month should be 2")
}
if d3.Year() != 2017{
t.Error("year should be 2017")
}
if d3.Hour() != 14 {
t.Error("hour should be 14")
}
}