@@ -78,7 +78,7 @@ func TestConvertTime(t *testing.T) {
78
78
ts := testTimestamp .Round (time .Millisecond )
79
79
row := & bq.TableRow {
80
80
F : []* bq.TableCell {
81
- {V : fmt .Sprintf ( "%.10f" , float64 ( ts .UnixNano ()) / 1e9 )},
81
+ {V : fmt .Sprint ( ts .UnixMicro () )},
82
82
{V : testDate .String ()},
83
83
{V : testTime .String ()},
84
84
{V : testDateTime .String ()},
@@ -95,15 +95,12 @@ func TestConvertTime(t *testing.T) {
95
95
t .Errorf ("#%d: got:\n %v\n want:\n %v" , i , g , w )
96
96
}
97
97
}
98
- if got [0 ].(time.Time ).Location () != time .UTC {
99
- t .Errorf ("expected time zone UTC: got:\n %v" , got )
100
- }
101
98
}
102
99
103
100
func TestConvertSmallTimes (t * testing.T ) {
104
101
for _ , year := range []int {1600 , 1066 , 1 } {
105
102
want := time .Date (year , time .January , 1 , 0 , 0 , 0 , 0 , time .UTC )
106
- s := fmt .Sprintf ( "%.10f" , float64 ( want . Unix () ))
103
+ s := fmt .Sprint ( time . Date ( year , time . January , 1 , 0 , 0 , 0 , 0 , time . UTC ). UnixMicro ( ))
107
104
got , err := convertBasicType (s , TimestampFieldType )
108
105
if err != nil {
109
106
t .Fatal (err )
@@ -114,44 +111,6 @@ func TestConvertSmallTimes(t *testing.T) {
114
111
}
115
112
}
116
113
117
- func TestConvertTimePrecision (t * testing.T ) {
118
- tcs := []struct {
119
- // Internally, BigQuery stores timestamps as microsecond-precision
120
- // floats.
121
- bq float64
122
- want time.Time
123
- }{
124
- {
125
- bq : 1555593697.154358 ,
126
- want : time .Unix (1555593697 , 154358 * 1000 ),
127
- },
128
- {
129
- bq : 1555593697.154359 ,
130
- want : time .Unix (1555593697 , 154359 * 1000 ),
131
- },
132
- {
133
- bq : 1555593697.154360 ,
134
- want : time .Unix (1555593697 , 154360 * 1000 ),
135
- },
136
- }
137
- for _ , tc := range tcs {
138
- bqS := fmt .Sprintf ("%.6f" , tc .bq )
139
- t .Run (bqS , func (t * testing.T ) {
140
- got , err := convertBasicType (bqS , TimestampFieldType )
141
- if err != nil {
142
- t .Fatalf ("convertBasicType failed: %v" , err )
143
- }
144
- gotT , ok := got .(time.Time )
145
- if ! ok {
146
- t .Fatalf ("got a %T from convertBasicType, want a time.Time; got = %v" , got , got )
147
- }
148
- if ! gotT .Equal (tc .want ) {
149
- t .Errorf ("got %v from convertBasicType, want %v" , gotT , tc .want )
150
- }
151
- })
152
- }
153
- }
154
-
155
114
func TestConvertNullValues (t * testing.T ) {
156
115
schema := Schema {{Type : StringFieldType }}
157
116
row := & bq.TableRow {
0 commit comments