daytime

package module
v0.0.0-...-4e0fc11 Latest Latest
Warning

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

Go to latest
Published: May 8, 2025 License: MIT Imports: 7 Imported by: 0

README

Daytime

Golang package for working with time of day

Get package

go get github.com/SPTolkachev/daytime

Create

Create a new daytime

daytime := New(hour int, minute int, second int)

Parse a daytime

daytime := Parse("15:04:05")

Convert to string

str := daytime.String()
fmt.Println(str) // 15:04:05

Convert to time

Bringing to the current day's time.

daytime.Time()

Bringing to the near future.

daytime.InTheNearFuture()

Bringing to the recent past.

daytime.InTheRecentPast()

Documentation

Index

Constants

View Source
const (
	Day         = 24 * time.Hour
	DefaultTime = "00:00"
)

Variables

View Source
var (
	ErrObjIsNil   = errors.New("object is nil")
	ErrInvalid    = errors.New("invalid")
	ErrUnexpected = errors.New("unexpected")
)

Functions

This section is empty.

Types

type DayTime

type DayTime struct {
	// contains filtered or unexported fields
}

func New

func New(hour int, minute int, second int) (DayTime, error)

New create a new daytime.

func Parse

func Parse(value string) (DayTime, error)

Parse parse a daytime.

func (*DayTime) InTheNearFuture

func (t *DayTime) InTheNearFuture() time.Time

InTheNearFuture bringing to the current day's time.

func (*DayTime) InTheRecentPast

func (t *DayTime) InTheRecentPast() time.Time

InTheRecentPast bringing to the near future.

func (*DayTime) MarshalBinary

func (t *DayTime) MarshalBinary() ([]byte, error)

func (*DayTime) MarshalCSV

func (t *DayTime) MarshalCSV() (string, error)

func (*DayTime) MarshalJSON

func (t *DayTime) MarshalJSON() ([]byte, error)

func (*DayTime) MarshalText

func (t *DayTime) MarshalText() ([]byte, error)

func (*DayTime) Scan

func (t *DayTime) Scan(src any) error

func (*DayTime) String

func (t *DayTime) String() string

String convert to string.

func (*DayTime) Time

func (t *DayTime) Time() time.Time

Time bringing to the current day's time.

func (*DayTime) UnmarshalBinary

func (t *DayTime) UnmarshalBinary(data []byte) error

func (*DayTime) UnmarshalCSV

func (t *DayTime) UnmarshalCSV(str string) error

func (*DayTime) UnmarshalJSON

func (t *DayTime) UnmarshalJSON(data []byte) error

func (*DayTime) UnmarshalText

func (t *DayTime) UnmarshalText(data []byte) error

func (*DayTime) Value

func (t *DayTime) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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