-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathjulian_test.go
121 lines (102 loc) · 2.58 KB
/
julian_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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package gocalendar
import (
"testing"
"time"
)
func TestJulianDay(t *testing.T) {
jd := JulianDay(1581,1,1,12)
if Round(jd,10) == 2298519 {
t.Log("passed")
}else{
t.Error(jd)
}
jd = JulianDay(2021,12,6)
if Round(jd,10) == 2459554.5 {
t.Log("passed")
}else{
t.Error(jd)
}
jd = JulianDay(2021,12,6,12)
if Round(jd,10) == 2459555 {
t.Log("passed")
}else{
t.Error(jd)
}
jd = JulianDay(2021,12,6,12,10,10)
if Round(jd,10) == 2459555.007060185 {
t.Log("passed")
}else{
t.Error(jd)
}
}
func TestMjd(t *testing.T) {
jd := Mjd(2021,12,6)
if Round(jd,10) == 59554 {
t.Log("passed")
}else{
t.Error(jd)
}
jd = Mjd(2021,12,6,12)
if Round(jd,10) == 59554.5 {
t.Log("passed")
}else{
t.Error(jd)
}
jd = Mjd(2021,12,6,12,10,10)
if Round(jd,10) == 59554.5070601851 {
t.Log("passed")
}else{
t.Error(jd)
}
}
func TestJdToTimeMap(t *testing.T) {
datetime := JdToTimeMap(2298519)
if datetime["year"] == 1581 && datetime["month"] == 1 && datetime["day"] == 1 && datetime["hour"] == 12 {
t.Log("passed")
}else{
t.Error(datetime)
}
datetime = JdToTimeMap(2459554.5)
if datetime["year"] == 2021 && datetime["month"] == 12 && datetime["day"] == 6 {
t.Log("passed")
}else{
t.Error(datetime)
}
datetime = JdToTimeMap(2459555)
if datetime["year"] == 2021 && datetime["month"] == 12 && datetime["day"] == 6 && datetime["hour"] == 12 {
t.Log("passed")
}else{
t.Error(datetime)
}
datetime = JdToTimeMap(2459555.007060185)
if datetime["year"] == 2021 && datetime["month"] == 12 && datetime["day"] == 6 && datetime["hour"] == 12 && datetime["minute"] == 10 && datetime["second"] == 10 {
t.Log("passed")
}else{
// fmt.Printf("%d年%d月%d日%d时%d分%d秒\n",datetime["year"], datetime["month"],datetime["day"],datetime["hour"],datetime["minute"],datetime["second"])
t.Error(datetime)
}
}
func TestJdToTime(t *testing.T) {
datetime := JdToTime(2459555.007060185,time.Local)
t.Log(datetime.Format(time.RFC3339))
}
func TestMjdToTimeMap(t *testing.T) {
datetime := MjdToTimeMap(59554)
if datetime["year"] == 2021 && datetime["month"] == 12 && datetime["day"] == 6 {
t.Log("passed")
}else{
t.Error(datetime)
}
datetime = MjdToTimeMap(59554.5)
if datetime["year"] == 2021 && datetime["month"] == 12 && datetime["day"] == 6 && datetime["hour"] == 12 {
t.Log("passed")
}else{
t.Error(datetime)
}
datetime = MjdToTimeMap(59554.507060185075)
if datetime["year"] == 2021 && datetime["month"] == 12 && datetime["day"] == 6 && datetime["hour"] == 12 && datetime["minute"] == 10 && datetime["second"] == 10 {
t.Log("passed")
}else{
t.Error(datetime)
}
}