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

Function appendMicrosecs

utils.go:339–386  ·  view source on GitHub ↗
(dst, src []byte, decimals int)

Source from the content-addressed store, hash-verified

337const digits10 = "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999"
338
339func appendMicrosecs(dst, src []byte, decimals int) []byte {
340 if decimals <= 0 {
341 return dst
342 }
343 if len(src) == 0 {
344 return append(dst, ".000000"[:decimals+1]...)
345 }
346
347 microsecs := binary.LittleEndian.Uint32(src[:4])
348 p1 := byte(microsecs / 10000)
349 microsecs -= 10000 * uint32(p1)
350 p2 := byte(microsecs / 100)
351 microsecs -= 100 * uint32(p2)
352 p3 := byte(microsecs)
353
354 switch decimals {
355 default:
356 return append(dst, '.',
357 digits10[p1], digits01[p1],
358 digits10[p2], digits01[p2],
359 digits10[p3], digits01[p3],
360 )
361 case 1:
362 return append(dst, '.',
363 digits10[p1],
364 )
365 case 2:
366 return append(dst, '.',
367 digits10[p1], digits01[p1],
368 )
369 case 3:
370 return append(dst, '.',
371 digits10[p1], digits01[p1],
372 digits10[p2],
373 )
374 case 4:
375 return append(dst, '.',
376 digits10[p1], digits01[p1],
377 digits10[p2], digits01[p2],
378 )
379 case 5:
380 return append(dst, '.',
381 digits10[p1], digits01[p1],
382 digits10[p2], digits01[p2],
383 digits10[p3],
384 )
385 }
386}
387
388func formatBinaryDateTime(src []byte, length uint8) (driver.Value, error) {
389 // length expects the deterministic length of the zero value,

Callers 2

formatBinaryDateTimeFunction · 0.85
formatBinaryTimeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected