MCPcopy Create free account
hub / github.com/cli/cli / relativeToNow

Function relativeToNow

pkg/cmd/auth/status/status.go:79–85  ·  view source on GitHub ↗

relativeToNow renders a fuzzy, human readable description of when t occurs relative to the current time, for annotating the absolute expiry timestamp. Future times read as "in about 7 hours" and already-elapsed times as "expired about 2 days ago".

(t time.Time)

Source from the content-addressed store, hash-verified

77// annotating the absolute expiry timestamp. Future times read as "in about 7 hours" and already-elapsed times as
78// "expired about 2 days ago".
79func relativeToNow(t time.Time) string {
80 now := timeNow()
81 if t.After(now) {
82 return text.FuzzyIn(now, t)
83 }
84 return "expired " + text.FuzzyAgo(now, t)
85}
86
87func (e authEntry) String(cs *iostreams.ColorScheme) string {
88 var sb strings.Builder

Callers 1

writeExpiryMethod · 0.85

Calls 2

FuzzyInFunction · 0.92
FuzzyAgoFunction · 0.92

Tested by

no test coverage detected