MCPcopy
hub / github.com/go-sql-driver/mysql / parseByteNanoSec

Function parseByteNanoSec

utils.go:208–221  ·  utils.go::parseByteNanoSec
(b []byte)

Source from the content-addressed store, hash-verified

206}
207
208func parseByteNanoSec(b []byte) (int, error) {
209 ns, digit := 0, 100000 // max is 6-digits
210 for i := range b {
211 v, err := bToi(b[i])
212 if err != nil {
213 return 0, err
214 }
215 ns += v * digit
216 digit /= 10
217 }
218 // nanoseconds has 10-digits. (needs to scale digits)
219 // 10 - 6 = 4, so we have to multiple 1000.
220 return ns * 1000, nil
221}
222
223func bToi(b byte) (int, error) {
224 if b < '0' || b > '9' {

Callers 1

parseDateTimeFunction · 0.85

Calls 1

bToiFunction · 0.85

Tested by

no test coverage detected