duration

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 7 Imported by: 0

README

go-duration

Модуль для парсинга и форматирования временных интервалов ISO8601.

Установка

go get git.ymnuktech.ru/ymnuk/go-duration

Пример использования

package duration

import (
	"fmt"
	"time"
)

func main() {
	d := Duration(time.Second*12 + 500*time.Millisecond + time.Minute*5 + time.Hour*8 + time.Hour*24*12 + time.Hour*24*30*6 + time.Hour*24*365*5)
	fmt.Println(d.Format())

	fmt.Println(d.Parse(d.Format()))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(d Duration) string

Types

type Duration

type Duration time.Duration

func (*Duration) Format

func (d *Duration) Format() string

func (*Duration) MarshalJSON

func (d *Duration) MarshalJSON() ([]byte, error)

func (*Duration) MarshalXML

func (d *Duration) MarshalXML(e *xml.Encoder, start xml.StartElement) error

func (*Duration) MarshalXMLAttr

func (d *Duration) MarshalXMLAttr(name xml.Name) (xml.Attr, error)

func (*Duration) Parse

func (d *Duration) Parse(iso8601 string) (Duration, error)

Parsing ISO8601 format

func (Duration) String added in v0.0.2

func (d Duration) String() string

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

func (*Duration) UnmarshalXML

func (d *Duration) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

func (*Duration) UnmarshalXMLAttr

func (d *Duration) UnmarshalXMLAttr(attr xml.Attr) error

Jump to

Keyboard shortcuts

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