Skip to content

Commit db91787

Browse files
committed
all tests passing
1 parent 1009a04 commit db91787

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

packets.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"fmt"
1717
"io"
1818
"math"
19-
"strconv"
2019
"time"
2120
)
2221

@@ -1103,35 +1102,36 @@ func (rows *binaryRows) readRow(dest []driver.Value) error {
11031102
}
11041103
}
11051104

1106-
var sign string
1105+
var result string
11071106
if data[pos] == 1 {
1108-
sign = "-"
1107+
result = "-"
11091108
}
1110-
1109+
var microsecs uint32
11111110
switch num {
11121111
case 8:
1113-
dest[i] = []byte(fmt.Sprintf(
1114-
sign+"%02d:%02d:%02d",
1112+
result += fmt.Sprintf(
1113+
"%02d:%02d:%02d",
11151114
uint16(data[pos+1])*24+uint16(data[pos+5]),
11161115
data[pos+6],
11171116
data[pos+7],
1118-
))
1117+
)
11191118
pos += 8
1120-
continue
11211119
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",
11251122
uint16(data[pos+1])*24+uint16(data[pos+5]),
11261123
data[pos+6],
11271124
data[pos+7],
1128-
binary.LittleEndian.Uint32(data[pos+8:pos+12]),
1129-
))
1125+
)
1126+
microsecs = binary.LittleEndian.Uint32(data[pos+8 : pos+12])
11301127
pos += 12
1131-
continue
11321128
default:
11331129
return fmt.Errorf("Invalid TIME-packet length %d", num)
11341130
}
1131+
if decimals := rows.columns[i].decimals; decimals > 0 {
1132+
result += fmt.Sprintf(".%06d", microsecs)[:1+decimals]
1133+
}
1134+
dest[i] = []byte(result)
11351135

11361136
// Timestamp YYYY-MM-DD HH:MM:SS[.fractal]
11371137
case fieldTypeTimestamp, fieldTypeDateTime:

0 commit comments

Comments
 (0)