repo init

This commit is contained in:
ayurishchev committed 2026-08-21 07:34:45 +03:00
commit 7e44db87b2
48 files changed
+5346

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
package db
import (
"database/sql"
"time"
)
// Timestamps are stored as RFC3339Nano TEXT explicitly (rather than relying
// on driver-specific time.Time marshaling) so the on-disk format is stable
// and easy to inspect with the sqlite3 CLI.
const timeLayout = time.RFC3339Nano
func timeToDB(t time.Time) string {
return t.UTC().Format(timeLayout)
}
func timePtrToDB(t *time.Time) interface{} {
if t == nil {
return nil
}
return timeToDB(*t)
}
func dbToTime(s string) (time.Time, error) {
return time.Parse(timeLayout, s)
}
func nullStringToTimePtr(ns sql.NullString) (*time.Time, error) {
if !ns.Valid || ns.String == "" {
return nil, nil
}
t, err := dbToTime(ns.String)
if err != nil {
return nil, err
}
return &t, nil
}