Add a Clock interface and default real-clock implementation so production code can use clock.Now() instead of time.Now(), and tests can inject a fake clock for deterministic timeouts and scheduling. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
11 lines
322 B
Go
11 lines
322 B
Go
package clock
|
|
|
|
import "time"
|
|
|
|
// Now returns the current UTC time, used everywhere for wall-clock consistency.
|
|
// All scheduling comparisons, timestamp recording, and duration calculations use
|
|
// this function so they're consistent with the database (TIMESTAMPTZ in UTC).
|
|
func Now() time.Time {
|
|
return time.Now().UTC()
|
|
}
|