File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ import (
16
16
"fmt"
17
17
"io"
18
18
"math"
19
- "strconv"
20
19
"time"
21
20
)
22
21
@@ -1103,35 +1102,36 @@ func (rows *binaryRows) readRow(dest []driver.Value) error {
1103
1102
}
1104
1103
}
1105
1104
1106
- var sign string
1105
+ var result string
1107
1106
if data [pos ] == 1 {
1108
- sign = "-"
1107
+ result = "-"
1109
1108
}
1110
-
1109
+ var microsecs uint32
1111
1110
switch num {
1112
1111
case 8 :
1113
- dest [ i ] = [] byte ( fmt .Sprintf (
1114
- sign + "%02d:%02d:%02d" ,
1112
+ result += fmt .Sprintf (
1113
+ "%02d:%02d:%02d" ,
1115
1114
uint16 (data [pos + 1 ])* 24 + uint16 (data [pos + 5 ]),
1116
1115
data [pos + 6 ],
1117
1116
data [pos + 7 ],
1118
- ))
1117
+ )
1119
1118
pos += 8
1120
- continue
1121
1119
case 12 :
1122
- decimals := strconv .FormatInt (int64 (rows .columns [i ].decimals ), 10 )
1123
- dest [i ] = []byte (fmt .Sprintf (
1124
- sign + "%02d:%02d:%02d.%0" + decimals + "d" ,
1120
+ result += fmt .Sprintf (
1121
+ "%02d:%02d:%02d" ,
1125
1122
uint16 (data [pos + 1 ])* 24 + uint16 (data [pos + 5 ]),
1126
1123
data [pos + 6 ],
1127
1124
data [pos + 7 ],
1128
- binary . LittleEndian . Uint32 ( data [ pos + 8 : pos + 12 ]),
1129
- ) )
1125
+ )
1126
+ microsecs = binary . LittleEndian . Uint32 ( data [ pos + 8 : pos + 12 ] )
1130
1127
pos += 12
1131
- continue
1132
1128
default :
1133
1129
return fmt .Errorf ("Invalid TIME-packet length %d" , num )
1134
1130
}
1131
+ if decimals := rows .columns [i ].decimals ; decimals > 0 {
1132
+ result += fmt .Sprintf (".%06d" , microsecs )[:1 + decimals ]
1133
+ }
1134
+ dest [i ] = []byte (result )
1135
1135
1136
1136
// Timestamp YYYY-MM-DD HH:MM:SS[.fractal]
1137
1137
case fieldTypeTimestamp , fieldTypeDateTime :
You can’t perform that action at this time.
0 commit comments