time

package
v1.1.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2021 License: MIT Imports: 11 Imported by: 6

Documentation

Index

Constants

View Source
const (

	// DefaultInitialInterval The default initial interval value (0.5 seconds).
	DefaultInitialInterval = 500 * time.Millisecond

	// DefaultRandomizationFactor The default randomization factor (0.5 which results in a random period ranging between 50%
	// below and 50% above the retry interval).
	DefaultRandomizationFactor = 0.5

	// DefaultMultiplier The default multiplier value (1.5 which is 50% increase per back off).
	DefaultMultiplier = 1.5

	// DefaultMaxInterval The default maximum back off time (1 minute).
	DefaultMaxInterval = time.Minute

	// DefaultMaxElapsedDuration The default maximum elapsed time (15 minutes).
	DefaultMaxElapsedDuration = 15 * time.Minute

	// DefaultMaxElapsedCount The default maximum elapsed count (-1).
	DefaultMaxElapsedCount = -1
)
View Source
const InfDuration = time.Duration(1<<63 - 1)

InfDuration is the duration returned by Delay when a Reservation is not OK.

View Source
const ZeroBackOff = NonSlidingBackOff(0)

ZeroBackOff Fixed back-off policy whose back-off time is always zero, meaning that the operation is retried

immediately without waiting.

Variables

This section is empty.

Functions

func After

func After(d time.Duration) <-chan time.Time

func BackoffUntil added in v0.0.95

func BackoffUntil(ctx context.Context, f func(ctx context.Context), backoff BackOff, sliding bool)

BackoffUntil loops until context is done, run f every duration given by BackoffManager. BackoffUntil is syntactic sugar on top of BackoffUntilWithReset, without resetCh.

func BackoffUntilWithReset added in v0.0.150

func BackoffUntilWithReset(ctx context.Context,
	f func(ctx context.Context), resetCh chan struct{}, backoff BackOff, sliding bool)

BackoffUntilWithReset loops until context is done, run f every duration given by BackoffManager.

If sliding is true, the period is computed after f runs. If it is false then period includes the runtime for f. backoff is reset if resetCh has data

func ConvertTimestamp added in v0.0.142

func ConvertTimestamp(timestamp int64, from, to time.Duration) int64

ConvertTimestamp convert timestamp from one unit to another unit

func Forever added in v0.0.95

func Forever(f func(), period time.Duration)

Forever calls f every period for ever.

Forever is syntactic sugar on top of Forever, without resetCh. Example: time.Second 2021/04/09 12:45:08 Apr 9 12:45:08 2021/04/09 12:45:09 Apr 9 12:45:09 2021/04/09 12:45:10 Apr 9 12:45:10 2021/04/09 12:45:11 Apr 9 12:45:11 2021/04/09 12:45:12 Apr 9 12:45:12 2021/04/09 12:45:13 Apr 9 12:45:13 2021/04/09 12:45:14 Apr 9 12:45:14

func ForeverWithReset added in v0.0.150

func ForeverWithReset(f func(), resetCh chan struct{}, period time.Duration)

ForeverWithReset calls f every period for ever.

ForeverWithReset is syntactic sugar on top of UntilWithReset. Example: time.Second 2021/04/09 12:45:08 Apr 9 12:45:08 2021/04/09 12:45:09 Apr 9 12:45:09 2021/04/09 12:45:10 Apr 9 12:45:10 2021/04/09 12:45:11 Apr 9 12:45:11 2021/04/09 12:45:12 Apr 9 12:45:12 2021/04/09 12:45:13 Apr 9 12:45:13 2021/04/09 12:45:14 Apr 9 12:45:14

func Jitter added in v0.0.95

func Jitter(duration time.Duration, maxFactor float64) time.Duration

Jitter returns a time.Duration between [duration - maxFactor*duration, duration + maxFactor*duration].

This allows clients to avoid converging on periodic behavior.

func JitterBackOff added in v0.0.119

func JitterBackOff(duration time.Duration, maxFactor float64) *jitterBackOff

JitterBackOff returns a time.Duration between [duration - maxFactor*duration, duration + maxFactor*duration].

This allows clients to avoid converging on periodic behavior.

func JitterUntil added in v0.0.95

func JitterUntil(ctx context.Context, f func(ctx context.Context), sliding bool, opts ...ExponentialBackOffOption)

JitterUntil loops until context is done, running f every period. JitterUntil is syntactic sugar on top of JitterUntilWithReset, without resetCh.

func JitterUntilWithReset added in v0.0.150

func JitterUntilWithReset(ctx context.Context, f func(ctx context.Context), resetCh chan struct{}, sliding bool, opts ...ExponentialBackOffOption)

JitterUntilWithReset loops until context is done, running f every period.

period set by WithExponentialBackOffOptionInitialInterval jitterFactor set by WithExponentialBackOffOptionRandomizationFactor If jitterFactor is positive, the period is jittered before every run of f. If jitterFactor is not positive, the period is unchanged and not jittered.

If sliding is true, the period is computed after f runs. If it is false then period includes the runtime for f. backoff is reset if resetCh has data

Cancel context to stop. f may not be invoked if context is already expired.

func LayoutStrftimeToSimilarTime added in v0.0.135

func LayoutStrftimeToSimilarTime(layout string) string

func LayoutStrftimeToTime added in v0.0.135

func LayoutStrftimeToTime(layout string) string

func LayoutTimeToSimilarStrftime added in v0.0.135

func LayoutTimeToSimilarStrftime(layout string) string

func LayoutTimeToStrftime added in v0.0.135

func LayoutTimeToStrftime(layout string) string

func NonSlidingUntil added in v0.0.95

func NonSlidingUntil(ctx context.Context, f func(ctx context.Context), period time.Duration)

NonSlidingUntil loops until context is done, running f every period.

NonSlidingUntil is syntactic sugar on top of NonSlidingUntilWithReset, without resetCh.

func NonSlidingUntilWithReset added in v0.0.150

func NonSlidingUntilWithReset(ctx context.Context, f func(ctx context.Context), resetCh chan struct{}, period time.Duration)

NonSlidingUntilWithReset loops until context is done, running f every period.

NonSlidingUntilWithReset is syntactic sugar on top of JitterUntilWithReset with zero jitter factor, with sliding = false (meaning the timer for period starts at the same time as the function starts). Example: time.Second for period and sleep in f 2021/04/09 12:45:08 Apr 9 12:45:08 2021/04/09 12:45:09 Apr 9 12:45:09 2021/04/09 12:45:10 Apr 9 12:45:10 2021/04/09 12:45:11 Apr 9 12:45:11 2021/04/09 12:45:12 Apr 9 12:45:12 2021/04/09 12:45:13 Apr 9 12:45:13 2021/04/09 12:45:14 Apr 9 12:45:14

func RatioFrom added in v0.0.108

func RatioFrom(from time.Duration, to time.Duration) (ratio time.Duration, divide bool)

Example: ratio, divide := RatioFrom(fromUnit, toUnit)

if divide {
  toDuration = fromDuration / ratio
  fromDuration = toDuration * ratio
} else {
  toDuration = fromDuration * ratio
  fromDuration = toDuration / ratio
}

func Timestamp added in v0.0.142

func Timestamp(t time.Time, unit time.Duration) int64

Timestamp convert time to timestamp reprensent in unit

func TruncateByLocation added in v0.0.135

func TruncateByLocation(t time.Time, d time.Duration) time.Time

TruncateByLocation only happens in local semantics, apparently. observed values for truncating given time with 24 Hour: before truncation: 2012-01-01 04:15:30 +0800 CST after truncation: 2012-01-01 00:00:00 +0800 CST

time.Truncate only happens in UTC semantics, apparently. observed values for truncating given time with 24 Hour:

before truncation: 2012-01-01 04:15:30 +0800 CST after truncation: 2011-12-31 08:00:00 +0800 CST

This is really annoying when we want to truncate in local time we take the apparent local time in the local zone, and pretend that it's in UTC. do our math, and put it back to the local zone

func UnixWithUnit added in v0.0.108

func UnixWithUnit(timestamp int64, unit time.Duration) time.Time

UnixWithUnit returns the local Time corresponding to the given Unix time by unit

func Until added in v0.0.95

func Until(ctx context.Context, f func(ctx context.Context), period time.Duration)

Until loops until context is done, running f every period.

Until is syntactic sugar on top of UntilWithReset, without resetCh.

func UntilWithReset added in v0.0.150

func UntilWithReset(ctx context.Context, f func(ctx context.Context), resetCh chan struct{}, period time.Duration)

UntilWithReset loops until context is done, running f every period.

UntilWithReset is syntactic sugar on top of JitterUntilWithReset with zero jitter factor and with sliding = true (which means the timer for period starts after the f completes). Example: time.Second for period and sleep in f 2021/04/09 12:48:03 Apr 9 12:48:03 2021/04/09 12:48:05 Apr 9 12:48:05 2021/04/09 12:48:07 Apr 9 12:48:07 2021/04/09 12:48:09 Apr 9 12:48:09 2021/04/09 12:48:11 Apr 9 12:48:11 2021/04/09 12:48:13 Apr 9 12:48:13

Types

type BackOff added in v0.0.87

type BackOff interface {
	// Reset to initial state.
	Reset()

	// NextBackOff Gets duration to wait before retrying the operation to
	// indicate that no retries should be made.
	// ok indicates that no more retries should be made, max duration is returned also.
	// Example usage:
	// var backOffDuration, ok = backoff.NextBackOff();
	// if (!ok) {
	// 	// do not retry operation
	// } else {
	//	// sleep for backOffDuration milliseconds and retry operation
	// }
	NextBackOff() (backoff time.Duration, ok bool)
}

BackOff Code borrowed from https://github.com/googleapis/google-http-java-client/blob/master/google-http-client/ src/main/java/com/google/api/client/util/BackOff.java

type Cost added in v0.0.87

type Cost struct {
	// contains filtered or unexported fields
}

func (*Cost) Elapse added in v0.0.87

func (c *Cost) Elapse() time.Duration

func (*Cost) ElapseFunc added in v0.0.128

func (c *Cost) ElapseFunc(f func(d time.Duration))

func (*Cost) Start added in v0.0.87

func (c *Cost) Start()

type CostTick added in v0.0.128

type CostTick struct {

	// Lesser reports whether the element with duration i
	// must sort before the element with duration j.
	// sorting in decreasing order of cost if Lesser is nil
	// behaves like Less in sort.Interface
	Lesser func(i time.Duration, j time.Duration) bool
	// contains filtered or unexported fields
}

func (CostTick) Costs added in v0.0.131

func (c CostTick) Costs() []time.Duration

func (CostTick) Format added in v0.0.131

func (c CostTick) Format(s fmt.State, verb rune)

func (CostTick) Len added in v0.0.131

func (c CostTick) Len() int

sorting in decreasing order of cost.

func (CostTick) Less added in v0.0.131

func (c CostTick) Less(i, j int) bool

func (*CostTick) Reset added in v0.0.128

func (c *CostTick) Reset()

func (*CostTick) Sort added in v0.0.131

func (c *CostTick) Sort()

Sort is a convenience method: x.Sort() calls Sort(x).

func (CostTick) String added in v0.0.128

func (c CostTick) String() string

func (*CostTick) Swap added in v0.0.131

func (c *CostTick) Swap(i, j int)

func (*CostTick) Tick added in v0.0.128

func (c *CostTick) Tick(msg string)

func (CostTick) Walk added in v0.0.131

func (c CostTick) Walk(f func(idx int, msg string, cost time.Duration, at time.Time) (next bool))

Walk iterate costs Walk stop if f(...) returns false.

type EmptyExponentialBackOffOption added in v0.0.93

type EmptyExponentialBackOffOption struct{}

EmptyExponentialBackOffOption does not alter the configuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type ExponentialBackOff added in v0.0.87

type ExponentialBackOff struct {
	// contains filtered or unexported fields
}

ExponentialBackOff Code borrowed from https://github.com/googleapis/google-http-java-client/blob/master/google-http-client/ src/main/java/com/google/api/client/util/ExponentialBackOff.java

func NewDefaultExponentialBackOff added in v0.0.150

func NewDefaultExponentialBackOff(opts ...ExponentialBackOffOption) *ExponentialBackOff

NewDefaultExponentialBackOff returns a backoff with default limit

func NewExponentialBackOff added in v0.0.87

func NewExponentialBackOff(opts ...ExponentialBackOffOption) *ExponentialBackOff

NewExponentialBackOff returns a no limit backoff

func NewGrpcExponentialBackOff added in v0.0.150

func NewGrpcExponentialBackOff(opts ...ExponentialBackOffOption) *ExponentialBackOff

NewGrpcExponentialBackOff is a backoff from configuration with the default values specified at https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md.

This should be useful for callers who want to configure backoff with non-default values only for a subset of the options.

func (*ExponentialBackOff) ApplyOptions added in v0.0.93

func (o *ExponentialBackOff) ApplyOptions(options ...ExponentialBackOffOption) *ExponentialBackOff

func (*ExponentialBackOff) GetCurrentInterval added in v0.0.87

func (o *ExponentialBackOff) GetCurrentInterval() time.Duration

GetCurrentInterval Returns the current retry interval.

func (*ExponentialBackOff) GetElapsedCount added in v0.0.119

func (o *ExponentialBackOff) GetElapsedCount() int

GetElapsedCount Returns the elapsed count since an {@link ExponentialBackOff} instance is created and is reset when {@link #reset()} is called.

func (*ExponentialBackOff) GetElapsedDuration added in v0.0.87

func (o *ExponentialBackOff) GetElapsedDuration() time.Duration

GetElapsedDuration Returns the elapsed time since an {@link ExponentialBackOff} instance is created and is reset when {@link #reset()} is called. The elapsed time is computed using {@link System#nanoTime()}.

func (*ExponentialBackOff) GetInitialInterval added in v0.0.87

func (o *ExponentialBackOff) GetInitialInterval() time.Duration

GetInitialInterval Returns the initial retry interval.

func (*ExponentialBackOff) GetMaxElapsedDuration added in v0.0.87

func (o *ExponentialBackOff) GetMaxElapsedDuration() time.Duration

GetMaxElapsedDuration Returns the maximum elapsed time. If the time elapsed since an {@link ExponentialBackOff} instance is created goes past the max_elapsed_time then the method {@link #NextBackOff()} starts returning STOP. The elapsed time can be reset by calling

func (*ExponentialBackOff) GetMaxInterval added in v0.0.87

func (o *ExponentialBackOff) GetMaxInterval() time.Duration

GetMaxInterval Returns the maximum value of the back off period. Once the current interval reaches this value it stops increasing.

func (*ExponentialBackOff) GetMultiplier added in v0.0.87

func (o *ExponentialBackOff) GetMultiplier() float64

GetMultiplier Returns the value to multiply the current interval with for each retry attempt.

func (*ExponentialBackOff) GetRandomValueFromInterval added in v0.0.87

func (o *ExponentialBackOff) GetRandomValueFromInterval(
	randomizationFactor float64, currentInterval time.Duration) time.Duration

GetRandomValueFromInterval Returns a random value from the interval [randomizationFactor * currentInterval, randomizationFactor * currentInterval].

func (*ExponentialBackOff) GetRandomizationFactor added in v0.0.87

func (o *ExponentialBackOff) GetRandomizationFactor() float64

GetRandomizationFactor Returns the randomization factor to use for creating a range around the retry interval. A randomization factor of 0.5 results in a random period ranging between 50% below and 50% above the retry interval.

func (*ExponentialBackOff) NextBackOff added in v0.0.87

func (o *ExponentialBackOff) NextBackOff() (backoff time.Duration, ok bool)

NextBackOff This method calculates the next back off interval using the formula: randomized_interval = retry_interval +/- (randomization_factor * retry_interval) Subclasses may override if a different algorithm is required.

func (*ExponentialBackOff) Reset added in v0.0.87

func (o *ExponentialBackOff) Reset()

Reset Sets the interval back to the initial retry interval and restarts the timer.

func (*ExponentialBackOff) SetDefault added in v0.0.150

func (o *ExponentialBackOff) SetDefault()

type ExponentialBackOffOption added in v0.0.93

type ExponentialBackOffOption interface {
	// contains filtered or unexported methods
}

A ExponentialBackOffOption sets options.

func WithExponentialBackOffOptionGRPC added in v0.0.150

func WithExponentialBackOffOptionGRPC() ExponentialBackOffOption

func WithExponentialBackOffOptionInitialInterval added in v0.0.93

func WithExponentialBackOffOptionInitialInterval(duration time.Duration) ExponentialBackOffOption

func WithExponentialBackOffOptionMaxElapsedCount added in v0.0.119

func WithExponentialBackOffOptionMaxElapsedCount(count int) ExponentialBackOffOption

func WithExponentialBackOffOptionMaxElapsedDuration added in v0.0.93

func WithExponentialBackOffOptionMaxElapsedDuration(duration time.Duration) ExponentialBackOffOption

func WithExponentialBackOffOptionMaxInterval added in v0.0.93

func WithExponentialBackOffOptionMaxInterval(maxInterval time.Duration) ExponentialBackOffOption

func WithExponentialBackOffOptionMultiplier added in v0.0.93

func WithExponentialBackOffOptionMultiplier(multiplier float64) ExponentialBackOffOption

func WithExponentialBackOffOptionNoLimit added in v0.0.150

func WithExponentialBackOffOptionNoLimit() ExponentialBackOffOption

func WithExponentialBackOffOptionRandomizationFactor added in v0.0.93

func WithExponentialBackOffOptionRandomizationFactor(factor float64) ExponentialBackOffOption

type ExponentialBackOffOptionFunc added in v0.0.93

type ExponentialBackOffOptionFunc func(*ExponentialBackOff)

ExponentialBackOffOptionFunc wraps a function that modifies ExponentialBackOff into an implementation of the ExponentialBackOffOption interface.

type NonSlidingBackOff added in v0.0.119

type NonSlidingBackOff time.Duration

NonSlidingBackOff Fixed back-off policy whose back-off time is always const, meaning that the operation is retried after waiting every duration.

func (*NonSlidingBackOff) NextBackOff added in v0.0.119

func (o *NonSlidingBackOff) NextBackOff() (backoff time.Duration, ok bool)

func (*NonSlidingBackOff) Reset added in v0.0.119

func (o *NonSlidingBackOff) Reset()

type StopBackOff added in v0.0.87

type StopBackOff struct{}

StopBackOff Fixed back-off policy that always returns {@code #STOP} for {@link #NextBackOff()}, meaning that the operation should not be retried.

func (*StopBackOff) NextBackOff added in v0.0.87

func (o *StopBackOff) NextBackOff() (backoff time.Duration, ok bool)

func (*StopBackOff) Reset added in v0.0.87

func (o *StopBackOff) Reset()

type Timer

type Timer struct {
	*time.Timer
}

Timer to fix time: Timer.Stop documentation example easily leads to deadlocks https://github.com/golang/go/issues/27169

func AfterFunc

func AfterFunc(d time.Duration, f func()) *Timer

func NewTimer

func NewTimer(d time.Duration) *Timer

func WrapTimer

func WrapTimer(t *time.Timer) *Timer

func (*Timer) Reset

func (t *Timer) Reset(d time.Duration) bool

Reset changes the timer to expire after duration d. Reset can be invoked anytime, which enhances std time.Reset Reset == std [Stop + drain + Reset] It returns true if the timer had been active, false if the timer had expired or been stopped.

func (*Timer) Stop

func (t *Timer) Stop() bool

Stop prevents the Timer from firing, with the channel drained. Stop ensures the channel is empty after a call to Stop. Stop == std [Stop + drain] It returns true if the call stops the timer, false if the timer has already expired or been stopped. Stop does not close the channel, to prevent a read from the channel succeeding incorrectly.

type UnixSecondTime added in v0.0.108

type UnixSecondTime struct {
	time.Time
}

func (UnixSecondTime) MarshalJSON added in v0.0.108

func (t UnixSecondTime) MarshalJSON() ([]byte, error)

func (UnixSecondTime) MarshalText added in v0.0.108

func (t UnixSecondTime) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. The time is formatted in Unix Seconds, with sub-second precision added if present.

func (UnixSecondTime) String added in v0.0.108

func (t UnixSecondTime) String() string

func (*UnixSecondTime) UnmarshalJSON added in v0.0.108

func (t *UnixSecondTime) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.

func (*UnixSecondTime) UnmarshalText added in v0.0.108

func (t *UnixSecondTime) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The time is expected to be in RFC 3339 format.

type UnixTime added in v0.0.108

type UnixTime = UnixSecondTime

type UnixTimeDay added in v0.0.108

type UnixTimeDay struct {
	time.Time
}

func (UnixTimeDay) MarshalJSON added in v0.0.108

func (t UnixTimeDay) MarshalJSON() ([]byte, error)

func (UnixTimeDay) MarshalText added in v0.0.108

func (t UnixTimeDay) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. The time is formatted in Unix Seconds, with sub-second precision added if present.

func (UnixTimeDay) String added in v0.0.108

func (t UnixTimeDay) String() string

func (*UnixTimeDay) UnmarshalJSON added in v0.0.108

func (t *UnixTimeDay) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.

func (*UnixTimeDay) UnmarshalText added in v0.0.108

func (t *UnixTimeDay) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The time is expected to be in RFC 3339 format.

type UnixTimeHour added in v0.0.108

type UnixTimeHour struct {
	time.Time
}

func (UnixTimeHour) MarshalJSON added in v0.0.108

func (t UnixTimeHour) MarshalJSON() ([]byte, error)

func (UnixTimeHour) MarshalText added in v0.0.108

func (t UnixTimeHour) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. The time is formatted in Unix Seconds, with sub-second precision added if present.

func (UnixTimeHour) String added in v0.0.108

func (t UnixTimeHour) String() string

func (*UnixTimeHour) UnmarshalJSON added in v0.0.108

func (t *UnixTimeHour) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.

func (*UnixTimeHour) UnmarshalText added in v0.0.108

func (t *UnixTimeHour) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The time is expected to be in RFC 3339 format.

type UnixTimeMicrosecond added in v0.0.108

type UnixTimeMicrosecond struct {
	time.Time
}

func (UnixTimeMicrosecond) MarshalJSON added in v0.0.108

func (t UnixTimeMicrosecond) MarshalJSON() ([]byte, error)

func (UnixTimeMicrosecond) MarshalText added in v0.0.108

func (t UnixTimeMicrosecond) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. The time is formatted in Unix Seconds, with sub-second precision added if present.

func (UnixTimeMicrosecond) String added in v0.0.108

func (t UnixTimeMicrosecond) String() string

func (*UnixTimeMicrosecond) UnmarshalJSON added in v0.0.108

func (t *UnixTimeMicrosecond) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.

func (*UnixTimeMicrosecond) UnmarshalText added in v0.0.108

func (t *UnixTimeMicrosecond) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The time is expected to be in RFC 3339 format.

type UnixTimeMillisecond added in v0.0.108

type UnixTimeMillisecond struct {
	time.Time
}

func (UnixTimeMillisecond) MarshalJSON added in v0.0.108

func (t UnixTimeMillisecond) MarshalJSON() ([]byte, error)

func (UnixTimeMillisecond) MarshalText added in v0.0.108

func (t UnixTimeMillisecond) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. The time is formatted in Unix Seconds, with sub-second precision added if present.

func (UnixTimeMillisecond) String added in v0.0.108

func (t UnixTimeMillisecond) String() string

func (*UnixTimeMillisecond) UnmarshalJSON added in v0.0.108

func (t *UnixTimeMillisecond) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.

func (*UnixTimeMillisecond) UnmarshalText added in v0.0.108

func (t *UnixTimeMillisecond) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The time is expected to be in RFC 3339 format.

type UnixTimeMinute added in v0.0.108

type UnixTimeMinute struct {
	time.Time
}

func (UnixTimeMinute) MarshalJSON added in v0.0.108

func (t UnixTimeMinute) MarshalJSON() ([]byte, error)

func (UnixTimeMinute) MarshalText added in v0.0.108

func (t UnixTimeMinute) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. The time is formatted in Unix Seconds, with sub-second precision added if present.

func (UnixTimeMinute) String added in v0.0.108

func (t UnixTimeMinute) String() string

func (*UnixTimeMinute) UnmarshalJSON added in v0.0.108

func (t *UnixTimeMinute) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.

func (*UnixTimeMinute) UnmarshalText added in v0.0.108

func (t *UnixTimeMinute) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The time is expected to be in RFC 3339 format.

type UnixTimeNanosecond added in v0.0.108

type UnixTimeNanosecond struct {
	time.Time
}

func (UnixTimeNanosecond) MarshalJSON added in v0.0.108

func (t UnixTimeNanosecond) MarshalJSON() ([]byte, error)

func (UnixTimeNanosecond) MarshalText added in v0.0.108

func (t UnixTimeNanosecond) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface. The time is formatted in Unix Seconds, with sub-second precision added if present.

func (UnixTimeNanosecond) String added in v0.0.108

func (t UnixTimeNanosecond) String() string

func (*UnixTimeNanosecond) UnmarshalJSON added in v0.0.108

func (t *UnixTimeNanosecond) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.

func (*UnixTimeNanosecond) UnmarshalText added in v0.0.108

func (t *UnixTimeNanosecond) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface. The time is expected to be in RFC 3339 format.

Directories

Path Synopsis
Package rate The key observation and some code (shr) is borrowed from time/rate/rate.go
Package rate The key observation and some code (shr) is borrowed from time/rate/rate.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL