Source File
time.go
Belonging Package
github.com/ncruces/go-sqlite3/driver
package driverimport ()// Convert a string in [time.RFC3339Nano] format into a [time.Time]// if it roundtrips back to the same string.// This way times can be persisted to, and recovered from, the database,// but if a string is needed, [database/sql] will recover the same string.func maybeTime( []byte) ( time.Time, bool) {// Weed out (some) values that can't possibly be// [time.RFC3339Nano] timestamps.if len() < len("2006-01-02T15:04:05Z") {return}if len() > len(time.RFC3339Nano) {return}if [4] != '-' || [10] != 'T' || [16] != ':' {return}// Slow path.var [len(time.RFC3339Nano)]byte, := time.Parse(time.RFC3339Nano, string())if == nil && bytes.Equal(, .AppendFormat([:0], time.RFC3339Nano)) {return , true}return}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |