odt

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2019 License: MIT Imports: 5 Imported by: 0

README

Golang Other Date Types

Build Status Go Report Card codecov GoDoc

Golang Other Date Types

Golang Library that translates between DATE and TIME SQL types and JSON encoding.

Features:

- automatically converts json to mysql scannable struct for DATE and TIME types

- can change the format read from the json

Example:

Look in the example folder

Change formats:

    odt.SetDateFormat("01/02/2006")
    odt.SetTimeFormat("22-22-22")

Documentation

Index

Constants

View Source
const DefaultLayout = "2006-01-02"
View Source
const DefaultTimeLayout = "15:04:05"

Variables

This section is empty.

Functions

func GetDateFormat

func GetDateFormat() string

func GetTimeFormat

func GetTimeFormat() string

func SetDateFormat

func SetDateFormat(f string)

func SetTimeFormat

func SetTimeFormat(f string)

Types

type Date

type Date struct {
	*time.Time
}

func NewDate

func NewDate(t time.Time) *Date

func (*Date) MarshalJSON

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

func (*Date) Scan

func (d *Date) Scan(value interface{}) error

Scan - Implement the database/sql scanner interface

func (*Date) UnmarshalJSON

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

func (Date) Value

func (d Date) Value() (driver.Value, error)

type Time

type Time struct {
	*time.Time
}

func NewTime

func NewTime(t time.Time) *Time

func ParseTimeFromBytes

func ParseTimeFromBytes(b []byte) (*Time, error)

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() ([]byte, error)

func (*Time) Scan

func (t *Time) Scan(value interface{}) error

Scan - Implement the database/sql scanner interface

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) (err error)

func (Time) Value

func (t Time) Value() (driver.Value, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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