time

package
v1.2.43 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 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 (
	// Deprecated: Use GLogDate instead.
	// See also https://github.com/google/glog/pull/530
	GLogShortDate = "0102 15:04:05.000000"     // mmdd hh:mm:ss.uuuuuu
	GLogDate      = "20060102 15:04:05.000000" // yyyymmdd hh:mm:ss.uuuuuu
)
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

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

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

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

ConvertTimestamp convert timestamp from one unit to another unit

func Forever

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

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

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

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

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

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

func LayoutStrftimeToSimilarTime(layout string) string

func LayoutStrftimeToTime

func LayoutStrftimeToTime(layout string) string

func LayoutTimeToSimilarStrftime

func LayoutTimeToSimilarStrftime(layout string) string

func LayoutTimeToStrftime

func LayoutTimeToStrftime(layout string) string

func NonSlidingUntil

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

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

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

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

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

func Timestamp

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

Timestamp returns a Unix timestamp in unit from "January 1, 1970 UTC". The result is undefined if the Unix time cannot be represented by an int64. Which includes calling TimeUnixMilli on a zero Time is undefined.

See Go stdlib https://golang.org/pkg/time/#Time.UnixNano for more information.

func TruncateByLocation

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

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

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

func Until

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

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

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

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

func (*Cost) Elapse

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

func (*Cost) ElapseFunc

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

func (*Cost) Start

func (c *Cost) Start()

type CostTick

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

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

func (CostTick) Format

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

func (CostTick) Len

func (c CostTick) Len() int

sorting in decreasing order of cost.

func (CostTick) Less

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

func (*CostTick) Reset

func (c *CostTick) Reset()

func (*CostTick) Sort

func (c *CostTick) Sort()

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

func (CostTick) String

func (c CostTick) String() string

func (*CostTick) Swap

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

func (*CostTick) Tick

func (c *CostTick) Tick(msg string)

func (CostTick) Walk

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 Duration added in v1.2.26

type Duration time.Duration

Duration is alias of time.Duration for marshal and unmarshal

func (Duration) MarshalJSON added in v1.2.26

func (d Duration) MarshalJSON() ([]byte, error)

func (Duration) MarshalText added in v1.2.26

func (d Duration) MarshalText() ([]byte, error)

func (*Duration) UnmarshalJSON added in v1.2.26

func (d *Duration) UnmarshalJSON(data []byte) error

func (*Duration) UnmarshalText added in v1.2.26

func (d *Duration) UnmarshalText(data []byte) error

type EmptyExponentialBackOffOption

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

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

func NewDefaultExponentialBackOff(opts ...ExponentialBackOffOption) *ExponentialBackOff

NewDefaultExponentialBackOff returns a backoff with default limit

func NewExponentialBackOff

func NewExponentialBackOff(opts ...ExponentialBackOffOption) *ExponentialBackOff

NewExponentialBackOff returns a no limit backoff

func NewGrpcExponentialBackOff

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

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

func (*ExponentialBackOff) GetCurrentInterval

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

GetCurrentInterval Returns the current retry interval.

func (*ExponentialBackOff) GetElapsedCount

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

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

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

GetInitialInterval Returns the initial retry interval.

func (*ExponentialBackOff) GetMaxElapsedDuration

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

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

func (o *ExponentialBackOff) GetMultiplier() float64

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

func (*ExponentialBackOff) GetRandomValueFromInterval

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

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

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

func (o *ExponentialBackOff) Reset()

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

func (*ExponentialBackOff) SetDefault

func (o *ExponentialBackOff) SetDefault()

type ExponentialBackOffOption

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

A ExponentialBackOffOption sets options.

func WithExponentialBackOffOptionGRPC

func WithExponentialBackOffOptionGRPC() ExponentialBackOffOption

func WithExponentialBackOffOptionInitialInterval

func WithExponentialBackOffOptionInitialInterval(duration time.Duration) ExponentialBackOffOption

func WithExponentialBackOffOptionMaxElapsedCount

func WithExponentialBackOffOptionMaxElapsedCount(count int) ExponentialBackOffOption

func WithExponentialBackOffOptionMaxElapsedDuration

func WithExponentialBackOffOptionMaxElapsedDuration(duration time.Duration) ExponentialBackOffOption

func WithExponentialBackOffOptionMaxInterval

func WithExponentialBackOffOptionMaxInterval(maxInterval time.Duration) ExponentialBackOffOption

func WithExponentialBackOffOptionMultiplier

func WithExponentialBackOffOptionMultiplier(multiplier float64) ExponentialBackOffOption

func WithExponentialBackOffOptionNoLimit

func WithExponentialBackOffOptionNoLimit() ExponentialBackOffOption

func WithExponentialBackOffOptionRandomizationFactor

func WithExponentialBackOffOptionRandomizationFactor(factor float64) ExponentialBackOffOption

type ExponentialBackOffOptionFunc

type ExponentialBackOffOptionFunc func(*ExponentialBackOff)

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

type NonSlidingBackOff

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

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

func (*NonSlidingBackOff) Reset

func (o *NonSlidingBackOff) Reset()

type StopBackOff

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

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

func (*StopBackOff) Reset

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

type UnixSecondTime struct {
	time.Time
}

func (UnixSecondTime) MarshalJSON

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

func (UnixSecondTime) MarshalText

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

func (t UnixSecondTime) String() string

func (*UnixSecondTime) UnmarshalJSON

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

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

type UnixTime = UnixSecondTime

type UnixTimeDay

type UnixTimeDay struct {
	time.Time
}

func (UnixTimeDay) MarshalJSON

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

func (UnixTimeDay) MarshalText

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

func (t UnixTimeDay) String() string

func (*UnixTimeDay) UnmarshalJSON

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

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

type UnixTimeHour struct {
	time.Time
}

func (UnixTimeHour) MarshalJSON

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

func (UnixTimeHour) MarshalText

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

func (t UnixTimeHour) String() string

func (*UnixTimeHour) UnmarshalJSON

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

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

type UnixTimeMicrosecond struct {
	time.Time
}

func (UnixTimeMicrosecond) MarshalJSON

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

func (UnixTimeMicrosecond) MarshalText

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

func (t UnixTimeMicrosecond) String() string

func (*UnixTimeMicrosecond) UnmarshalJSON

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

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

type UnixTimeMillisecond struct {
	time.Time
}

func (UnixTimeMillisecond) MarshalJSON

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

func (UnixTimeMillisecond) MarshalText

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

func (t UnixTimeMillisecond) String() string

func (*UnixTimeMillisecond) UnmarshalJSON

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

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

type UnixTimeMinute struct {
	time.Time
}

func (UnixTimeMinute) MarshalJSON

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

func (UnixTimeMinute) MarshalText

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

func (t UnixTimeMinute) String() string

func (*UnixTimeMinute) UnmarshalJSON

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

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

type UnixTimeNanosecond struct {
	time.Time
}

func (UnixTimeNanosecond) MarshalJSON

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

func (UnixTimeNanosecond) MarshalText

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

func (t UnixTimeNanosecond) String() string

func (*UnixTimeNanosecond) UnmarshalJSON

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

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