Alexey Kim 3 weeks ago
parent
commit
840d7a3507
1 changed files with 23 additions and 0 deletions
  1. 23 0
      clock.go

+ 23 - 0
clock.go

@@ -18,6 +18,29 @@ func (t ClockUTC) After(d time.Duration) <-chan time.Time {
 	return time.After(d)
 }
 
+type ClockNY struct {
+	location *time.Location
+}
+
+func NewClockNY() (Clock, error) {
+	l, err := time.LoadLocation("America/New_York")
+	if err != nil {
+		return nil, err
+	}
+
+	return ClockNY{
+		location: l,
+	}, nil
+}
+
+func (t ClockNY) Now() time.Time {
+	return time.Now().In(t.location)
+}
+
+func (t ClockNY) After(d time.Duration) <-chan time.Time {
+	return time.After(d)
+}
+
 type StubClock struct {
 	Clock time.Time
 }