medori

package module
v0.0.0-...-89d9e9d Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: MIT Imports: 5 Imported by: 0

README

Medori

A very simple custom type for working with Date, Datetime and Time especially when working with SQL datetime format.

Usage

Simply run go get -u github.com/dwadp/medori then import into your program.

Accepted Formats

Date

  • YYYY-MM-DD
  • DD-MM-YYYY
  • YYYY/MM/DD
  • DD/MM/YYYY

Datetime

  • YYYY-MM-DD HH:MM:SS
  • DD-MM-YYYY HH:MM:SS
  • YYYY/MM/DD HH:MM:SS
  • DD/MM/YYYY HH:MM:SS

Time

  • HH:MM:SS
Note

When marshalling to JSON of medori Date, Datetime or Time, the result format of it will still be like YYYY-MM-DD, YYYY-MM-DD HH:MM:SS or HH:MM:SS

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date struct {
	time.Time
}

func (*Date) MarshalJSON

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

Implementation of json.Marshall function

func (*Date) Scan

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

Implementation of sql.Scanner

func (*Date) String

func (d *Date) String() string

String returns the time formatted using the format string

func (*Date) UnmarshalJSON

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

Implementation for json.Unmarshal function

func (Date) Value

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

Implementation of driver.Valuer

type Datetime

type Datetime struct {
	time.Time
}

func (*Datetime) MarshalJSON

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

Implementation of json.Marshall function

func (*Datetime) Scan

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

Implementation of sql.Scanner

func (*Datetime) String

func (d *Datetime) String() string

String returns the time formatted using the format string

func (*Datetime) UnmarshalJSON

func (d *Datetime) UnmarshalJSON(data []byte) error

Implementation for json.Unmarshal function

func (Datetime) Value

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

Implementation of driver.Valuer

type Time

type Time struct {
	time.Time
}

func (*Time) MarshalJSON

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

Implementation of json.Marshall function

func (*Time) Scan

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

Implementation of sql.Scanner

func (*Time) String

func (d *Time) String() string

String returns the time formatted using the format string

func (*Time) UnmarshalJSON

func (d *Time) UnmarshalJSON(data []byte) error

Implementation for json.Unmarshal function

func (Time) Value

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

Implementation of driver.Valuer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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