duration

package
v1.8.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Duration

type Duration time.Duration

Duration adds marshalling to time.Duration.

func ParseDuration

func ParseDuration(s string) (Duration, error)

ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

func (Duration) Duration

func (d Duration) Duration() time.Duration

Duration returns this duration as time.Duration.

func (Duration) MarshalCQL

func (d Duration) MarshalCQL(info gocql.TypeInfo) ([]byte, error)

MarshalCQL implements gocql.Marshaler.

func (Duration) MarshalText

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

MarshalText implements text.Marshaller.

func (Duration) String

func (d Duration) String() string

String is a modified time.Duration String function that supports printing days with d suffix, note that day is equal to 24h. This is not supported by time.Duration because of issues with leap year and different time zones. We decide to ignore that as we are working with UTC.

The implementation is changed not to print units if value is 0 to keep the representation shorter i.e. instead of 7d0h0m0s we print just 7d.

String returns a string representing the duration in the form "72h3m0.5s". Leading zero units are omitted. As a special case, durations less than one second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure that the leading digit is non-zero. The zero duration formats as 0s.

func (*Duration) UnmarshalCQL

func (d *Duration) UnmarshalCQL(info gocql.TypeInfo, data []byte) error

UnmarshalCQL implements gocql.Unmarshaler.

func (*Duration) UnmarshalText

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

UnmarshalText implements text.Marshaller.

Jump to

Keyboard shortcuts

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