timeutil

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Unlicense Imports: 2 Imported by: 12

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 struct {
	time.Duration
}

Duration is a wrapper 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): Make it able to parse larger units like days.

Jump to

Keyboard shortcuts

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