time

package
v1.6.11 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	// Layout we use to format the time
	Layout = time.RFC3339
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatted

type Formatted time.Time

Formatted represents a custom time.Time for consistency across our application

Example
someTime, err := time.Parse("2006-01-02T15:04:05Z07:00", "2018-12-24T08:41:53Z")
if err != nil {
	fmt.Println(err.Error())
}
customTime := Formatted(someTime)

fmt.Println(customTime)
Output:

2018-12-24T08:41:53Z
Example (WithTimeZone)
someTime, err := time.Parse("2006-01-02T15:04:05Z07:00", "2018-12-24T08:41:53+07:00")
if err != nil {
	fmt.Println(err.Error())
}
customTime := Formatted(someTime)

fmt.Println(customTime)
Output:

2018-12-24T08:41:53+07:00

func NewUTCTime

func NewUTCTime() Formatted

NewUTCTime returns a Formatted object with location set to UTC

func (Formatted) MarshalJSON

func (d Formatted) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Formatted) String

func (d Formatted) String() string

String returns a string representing the time in RFC3339 format

func (*Formatted) UnmarshalJSON

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

UnmarshalJSON implements the json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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