types

package
v0.0.0-...-6fd8457 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package types provides custom types for the application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date time.Time

Date is a custom type that implements the MarshalJSON interface that applies date only formatting to the time.Time fields in order to avoid common time and timezone pitfalls when working with Times.

Examples:

"2019-01-01" -> time.Time{2019-01-01 00:00:00 +0000 UTC}
"2019-01-01T21:10:30Z" -> time.Time{2019-01-01 00:00:00 +0000 UTC}
"2019-01-01T21:10:30+01:00" -> time.Time{2019-01-01 00:00:00 +0000 UTC}

func DateFromString

func DateFromString(s string) Date

DateFromString returns a Date type from a string by parsing the string into a time.Time type and then stripping the time and timezone information.

Errors are ignored and an empty Date is returned.

func DateFromTime

func DateFromTime(t time.Time) Date

DateFromTime returns a Date type from a time.Time type by stripping the time and timezone information.

func (Date) MarshalJSON

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

func (Date) String

func (d Date) String() string

func (Date) Time

func (d Date) Time() time.Time

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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