// Now implements Clock.
546167
func (s *Simulated) Now() AbsTime {
	s.mu.RLock()
	defer s.mu.RUnlock()

	return s.now
}
1286588
func (v *NowValuer) Zone() *time.Location {
	if v.Location != nil {
		return v.Location
	}
	return nil
}
1206404
func (s *TickScheduler) Tick(now int64) {
	s.schedulerMu.Lock()
	defer s.schedulerMu.Unlock()

	if s.ctx == nil {
		return
	}

	select {
	case <-s.ctx.Done():
		return
	default:
		// do nothing and allow ticks
	}

	atomic.StoreInt64(&s.now, now)

	affected := 0
	for _, ts := range s.taskSchedulers {
		if nextDue, hasQueue := ts.NextDue(); now >= nextDue || hasQueue {
			ts.Work()
			affected++
		}
	}
	// TODO(mr): find a way to emit a more useful / less annoying tick message, maybe aggregated over the past 10s or 30s?
	s.logger.Debug("Ticked", zap.Int64("now", now), zap.Int("tasks_affected", affected))
}
320319
func (m *Monitor) update(n int) (now time.Duration) {
	if !m.active {
		return
	}
	if now = clock(); n > 0 {
		m.tLast = now
	}
	m.sBytes += int64(n)
	if sTime := now - m.sLast; sTime >= m.sRate {
		t := sTime.Seconds()
		if m.rSample = float64(m.sBytes) / t; m.rSample > m.rPeak {
			m.rPeak = m.rSample
		}

		// Exponential moving average using a method similar to *nix load
		// average calculation. Longer sampling periods carry greater weight.
		if m.samples > 0 {
			w := math.Exp(-t / m.rWindow)
			m.rEMA = m.rSample + w*(m.rEMA-m.rSample)
		} else {
			m.rEMA = m.rSample
		}
		m.reset(now)
	}
	return
}
278631
func (dt DateTime) Clock() (hour int, minute int, second int) {
	hour = dt.Hour()
	minute = dt.Minute()
	second = dt.Second()
	return
}
1289902
func (c Context) Now(format string) string {
	return time.Now().Format(format)
}
288234
func (b *Box) Time() time.Time {
	if b.IsEmbedded() {
		return b.embed.Time
	}

	//++ TODO: return time for appended box

	return time.Now()
}
516325
func (s *State) now() *timestamp.Timestamp {
	c := s.Clock
	if c == nil {
		c = clock.GetSystemClock()
	}
	return google.NewTimestamp(c.Now())
}
535631
func now() time.Duration {
	var now int64
	syscall.Syscall(queryPerformanceCounterProc.Addr(), 1, uintptr(unsafe.Pointer(&now)), 0, 0)
	return time.Duration(now) * time.Second / (time.Duration(qpcFrequency) * time.Nanosecond)
}
1089282
func (s *Stopwatch) Start() {
	s.Lock()
	defer s.Unlock()

	if !s.isRunning() {
		s.refTime = time.Now()
	}
}
872951
func (m *MockClock) Now() time.Time {
	m.cond.L.Lock()
	defer m.cond.L.Unlock()

	return m.now
}
218017
func (r *EwmaRate) Current(now time.Time) float64 {
	if r.lastTimestamp.IsZero() || r.lastTimestamp == now || now.Before(r.lastTimestamp) {
		return r.Ewma.Current
	}

	timeDelta := now.Sub(r.lastTimestamp)

	// Count as if nothing was received since last update and
	// don't save anything.
	return r.count(0, timeDelta)
}
273171
func nowInMillis(c clock.Clock) int64 {
	return c.Now().UnixNano() / int64(time.Millisecond)
}
829532
func (m *TimerMetrics) Status(startTime time.Time) {
	if m.statusEvery == 0 {
		return
	}
	m.StatusDuration(time.Now().Sub(startTime))
}
1286098
func Today(location string) (*Carbon, error) {
	l, err := time.LoadLocation(location)
	if err != nil {
		return nil, err
	}

	return NewCarbon(Now().In(l)), err
}
334445
func Clock(c timetools.TimeProvider) TtlMapOption {
	return func(m *TtlMap) error {
		m.clock = c
		return nil
	}
}
362031
func (s *Snapshotter) updateClock() {
	lastSeen := s.clock.Time() - 1
	if lastSeen > s.lastClock {
		s.lastClock = lastSeen
		s.tryAppend(fmt.Sprintf("clock: %d\n", s.lastClock))
	}
}