Documentation ¶
Index ¶
- type Duration
- func (d Duration) Duration() time.Duration
- func (d Duration) MarshalCQL(info gocql.TypeInfo) ([]byte, error)
- func (d Duration) MarshalText() ([]byte, error)
- func (d Duration) String() string
- func (d *Duration) UnmarshalCQL(info gocql.TypeInfo, data []byte) error
- func (d *Duration) UnmarshalText(b []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶
Duration adds marshalling to time.Duration.
func ParseDuration ¶
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) MarshalCQL ¶
MarshalCQL implements gocql.Marshaler.
func (Duration) MarshalText ¶
MarshalText implements text.Marshaller.
func (Duration) 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 ¶
UnmarshalCQL implements gocql.Unmarshaler.
func (*Duration) UnmarshalText ¶
UnmarshalText implements text.Marshaller.