func (m sqliteTimeWriter) TimeOrOffset(b builder, cl clockwork.Clock, too gregor.TimeOrOffset) { if too == nil { b.Build("NULL") return } if t := too.Time(); t != nil { b.Build("?", timeInUnix(*t)) return } if d := too.Offset(); d != nil { t := nowTime(cl).Add(*d) b.Build("?", timeInUnix(t)) return } b.Build("NULL") }
func (m mysqlTimeWriter) TimeOrOffset(b builder, cl clockwork.Clock, too gregor.TimeOrOffset) { if too == nil { b.Build("NULL") return } if t := too.Time(); t != nil { b.Build("?", *t) return } if d := too.Offset(); d != nil { b.Build("DATE_ADD(") m.Now(b, cl) b.Build(", INTERVAL ? MICROSECOND)", (d.Nanoseconds() / 1000)) return } b.Build("NULL") }
func (r *RekeyLogHandler) timeOrOffsetString(t gregor.TimeOrOffset) string { if t == nil { return "[empty]" } if t.Time() != nil { return fmt.Sprintf("time: %s", t.Time()) } if t.Offset() != nil { return fmt.Sprintf("offset: %s", t.Offset()) } return "[empty]" }
func toTime(now time.Time, t gregor.TimeOrOffset) time.Time { if t == nil { return now } if t.Time() != nil { return *t.Time() } if t.Offset() != nil { return now.Add(*t.Offset()) } return now }