Initial QSfera import

This commit is contained in:
Курнат Андрей
2026-06-07 10:20:04 +03:00
commit 2315f25754
16485 changed files with 4826827 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
//nolint:revive
package xtime
import (
"time"
)
func NewFakeClock() *FakeClock {
return NewFakeClockAt(time.Now())
}
func NewFakeClockAt(t time.Time) *FakeClock {
return &FakeClock{
time: t,
}
}
type FakeClock struct {
_ noCopy
// Not protected by a mutex. If a warning is thrown in your tests,
// just disable parallel tests.
time time.Time
}
func (c *FakeClock) Now() time.Time {
return c.time
}
func (c *FakeClock) Since(t time.Time) time.Duration {
return c.time.Sub(t)
}
func (c *FakeClock) Until(t time.Time) time.Duration {
return t.Sub(c.time)
}
func (c *FakeClock) Sleep(d time.Duration) {
c.time = c.time.Add(d)
}