mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
Time scanner.
This commit is contained in:
16
time.go
16
time.go
@@ -338,3 +338,19 @@ func (f TimeFormat) parseRelaxed(s string) (time.Time, error) {
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
||||
// Scanner returns a [database/sql.Scanner] that
|
||||
// decodes a time value into dest using this format.
|
||||
func (f TimeFormat) Scanner(dest *time.Time) interface{ Scan(any) error } {
|
||||
return timeScanner{dest, f}
|
||||
}
|
||||
|
||||
type timeScanner struct {
|
||||
*time.Time
|
||||
TimeFormat
|
||||
}
|
||||
|
||||
func (s timeScanner) Scan(src any) (err error) {
|
||||
*s.Time, err = s.Decode(src)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user