localtime

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalNorwegianDateTime

func MarshalNorwegianDateTime(t time.Time) ([]byte, error)

func MarshalRFC3339

func MarshalRFC3339(t time.Time) ([]byte, error)

func MarshalRFC3339Date

func MarshalRFC3339Date(t time.Time) ([]byte, error)

func MustLoadLocation

func MustLoadLocation(location string) *time.Location

func SetLocalTimeZone

func SetLocalTimeZone(location string)

Sets time.Location, which is used in the localtime package

func UnmarshalNorwegianDateTime

func UnmarshalNorwegianDateTime(data []byte) (*time.Time, error)

func UnmarshalRFC3339

func UnmarshalRFC3339(data []byte) (*time.Time, error)

func UnmarshalRFC3339Date

func UnmarshalRFC3339Date(data []byte) (*time.Time, error)

Types

type Date

type Date struct {
	time.Time
}

time.Time wrapper that formats and parses dates in RFC3339 date format. In the code and when marshalling to/from JSON, it's stored in the local timezone.

Before marshalling/unmarshalling, remember to set the local timezone with SetLocalTimeZone().

func ParseDate

func ParseDate(timestamp string) (*Date, error)

Parses timestamp in RFC3339 date format (yyyy-mm-dd), in local timezone.

func (Date) MarshalJSON

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

func (*Date) String

func (t *Date) String() string

func (*Date) UnmarshalJSON

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

type DateTime

type DateTime struct {
	time.Time
}

time.Time wrapper that formats and parses dates in RFC3339 datetime format, with or without timezone specified. In the code, the time is stored in UTC, but when it is marshalled to/from JSON, it is converted to the local timezone.

Before marshalling/unmarshalling, remember to set the local timezone with SetLocalTimeZone().

func ParseDateTime

func ParseDateTime(timestamp string) (*DateTime, error)

Parses timestamp in RFC3339 datetime format (yyyy-mm-ddThh:mm:ssZ). If timezone is omitted, it's interpreted as a local time.

func (DateTime) MarshalJSON

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

func (*DateTime) String

func (t *DateTime) String() string

func (*DateTime) UnmarshalJSON

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

type NorwegianDateTime

type NorwegianDateTime struct {
	time.Time
}

time.Time wrapper that formats and parses dates in dd.mm.yyyy hh:mm:ss format. In the code, the time is stored in UTC, but when it is marshalled to/from JSON, it is converted to the local timezone.

Before marshalling/unmarshalling, remember to set the local timezone with SetLocalTimeZone().

func ParseNorwegianDateTime

func ParseNorwegianDateTime(timestamp string) (*NorwegianDateTime, error)

Parses timestamp in dd.mm.yyyy hh:mm:ss format, interpreted as local time.

func (NorwegianDateTime) MarshalJSON

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

func (*NorwegianDateTime) String

func (t *NorwegianDateTime) String() string

func (*NorwegianDateTime) UnmarshalJSON

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

Jump to

Keyboard shortcuts

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