jsontime

package module
v0.0.0-...-6c40ca9 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-jsontime

A slim time.Time wrapper that handles pointer to time and formats the encoded time as RFC3339/ISO8601, which is easy to format and read from.

Usage

Either use jsontime.JSONTime as a pointer or the object itself, then just use it with the default json package.

type testJSON struct {
	Test JSONTime `json:"test"`
}

type testPtrJSON struct {
	Test *JSONTime `json:"test"`
}

For a more detailed usage example please have a look at the tests.

License

MIT License

Copyright (c) 2019 Alexander Pinnecke

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONTime

type JSONTime struct {
	time.Time
}

JSONTime handles parsing and formatting timestamps according the RFC3339/ISO8601 standard

func Now

func Now() JSONTime

Now returns the current time as JSONTime

func NowPtr

func NowPtr() *JSONTime

NowPtr returns the current time as pointer to JSONTime

func Ptr

func Ptr(t JSONTime) *JSONTime

Ptr is a convenience method that returns a pointer to the given JSONTime

func (JSONTime) MarshalJSON

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

MarshalJSON formats the timestamp as JSON

func (JSONTime) String

func (t JSONTime) String() string

String returns a string representation of the time.

Jump to

Keyboard shortcuts

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