time

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package time provides for custom types to translate time from JSON and other formats into time.Time objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DurationTime

type DurationTime struct {
	T time.Time
}

DurationTime provides a type that can marshal and unmarshal a string representation of a duration from now into a time.Time object. Note: I'm not sure this is the best way to do this. What happens is we get a field called "expires_in" that represents the seconds from now that this expires. We turn that into a time we call .ExpiresOn. But maybe we should be recording when the token was received at .TokenRecieved and .ExpiresIn should remain as a duration. Then we could have a method called ExpiresOn(). Honestly, the whole thing is bad because the server doesn't return a concrete time. I think this is cleaner, but its not great either.

func (DurationTime) MarshalJSON

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

MarshalJSON implements encoding/json.MarshalJSON().

func (*DurationTime) UnmarshalJSON

func (d *DurationTime) UnmarshalJSON(b []byte) error

UnmarshalJSON implements encoding/json.UnmarshalJSON().

type Unix

type Unix struct {
	T time.Time
}

Unix provides a type that can marshal and unmarshal a string representation of the unix epoch into a time.Time object.

func (Unix) MarshalJSON

func (u Unix) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.MarshalJSON().

func (*Unix) UnmarshalJSON

func (u *Unix) UnmarshalJSON(b []byte) error

UnmarshalJSON implements encoding/json.UnmarshalJSON().

Jump to

Keyboard shortcuts

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