timeutil

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Unlicense Imports: 3 Imported by: 13

Documentation

Overview

Package timeutil contains types and utilities for dealing with time and duration values.

Index

Constants

View Source
const Day time.Duration = 24 * time.Hour

Day is the duration of one day.

Variables

This section is empty.

Functions

This section is empty.

Types

type Duration

type Duration time.Duration

Duration is a helper type for time.Duration providing functionality for encoding.

func (Duration) MarshalText

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

MarshalText implements the encoding.TextMarshaler interface for Duration.

func (Duration) String

func (d Duration) String() (str string)

String implements the fmt.Stringer interface for Duration. It wraps time.Duration.String method and additionally cuts off non-leading zero values of minutes and seconds. Some values which are differ between the implementations:

Duration:   "1m", time.Duration:   "1m0s"
Duration:   "1h", time.Duration: "1h0m0s"
Duration: "1h1m", time.Duration: "1h1m0s"

func (*Duration) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler interface for *Duration.

TODO(e.burkov): Fix parsing larger units like days.

Jump to

Keyboard shortcuts

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