nnduration

package
v0.0.0-...-1e60831 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: NIST-PD-fallback Imports: 9 Imported by: 3

Documentation

Overview

Package nnduration provides JSON-friendly non-negative duration types.

Index

Constants

This section is empty.

Variables

View Source
var (
	GqlMilliseconds = makeGqlType(reflect.TypeOf(Milliseconds(0)))
	GqlNanoseconds  = makeGqlType(reflect.TypeOf(Nanoseconds(0)))
)

GraphQL types.

Functions

This section is empty.

Types

type Milliseconds

type Milliseconds uint64

Milliseconds is a duration in milliseconds unit.

func (Milliseconds) Duration

func (d Milliseconds) Duration() time.Duration

Duration converts this to time.Duration.

func (Milliseconds) DurationOr

func (d Milliseconds) DurationOr(dflt Milliseconds) time.Duration

DurationOr converts this to time.Duration, but returns dflt if this is zero.

func (*Milliseconds) UnmarshalJSON

func (d *Milliseconds) UnmarshalJSON(p []byte) (e error)

UnmarshalJSON implements json.Unmarshaler interface. It accepts either an integer as milliseconds, or a duration string recognized by time.ParseDuration.

type Nanoseconds

type Nanoseconds uint64

Nanoseconds is a duration in nanoseconds unit.

func (Nanoseconds) Duration

func (d Nanoseconds) Duration() time.Duration

Duration converts this to time.Duration.

func (Nanoseconds) DurationOr

func (d Nanoseconds) DurationOr(dflt Nanoseconds) time.Duration

DurationOr converts this to time.Duration, but returns dflt if this is zero.

func (*Nanoseconds) UnmarshalJSON

func (d *Nanoseconds) UnmarshalJSON(p []byte) (e error)

UnmarshalJSON implements json.Unmarshaler interface. It accepts either an integer as nanoseconds, or a duration string recognized by time.ParseDuration.

Jump to

Keyboard shortcuts

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