time

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package time contains a wrapper for time.Time in the standard library and associated methods. This package mainly exists to workaround an issue in Go where the serializer doesn't omit an empty value for time: https://github.com/golang/go/issues/11939. As such, this can be removed if a proposal is ever accepted for Go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Time

type Time struct {
	time.Time
}

Time is a convenience wrapper around stdlib time, but with different marshalling and unmarshaling for zero values

func Date

func Date(year int, month time.Month, day, hour, min, sec, nsec int, loc *time.Location) Time

func Now

func Now() Time

Now returns the current time. It is a convenience wrapper around time.Now()

func Parse

func Parse(layout, value string) (Time, error)

func ParseInLocation

func ParseInLocation(layout, value string, loc *time.Location) (Time, error)

func Unix

func Unix(sec int64, nsec int64) Time

func (Time) Add

func (t Time) Add(d time.Duration) Time

func (Time) AddDate

func (t Time) AddDate(years int, months int, days int) Time

func (Time) After

func (t Time) After(u Time) bool

func (Time) Before

func (t Time) Before(u Time) bool

func (Time) Equal

func (t Time) Equal(u Time) bool

func (Time) In

func (t Time) In(loc *time.Location) Time

func (Time) Local

func (t Time) Local() Time

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (Time) Round

func (t Time) Round(d time.Duration) Time

func (Time) Sub

func (t Time) Sub(u Time) time.Duration

func (Time) Truncate

func (t Time) Truncate(d time.Duration) Time

func (Time) UTC

func (t Time) UTC() Time

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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