toki

package module
v0.0.0-...-84b1fe5 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2015 License: BSD-2-Clause Imports: 6 Imported by: 0

README

toki GoDoc Coverage

import "github.com/guregu/toki"

toki (時) is a small library for handling the SQL TIME type. It has support for nullable TIME columns, as well as JSON (un)marshaling.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NullTime

type NullTime struct {
	Time
	Valid bool
}

NullTime is a nullable Time.

func MustParseNullTime

func MustParseNullTime(text string) NullTime

MustParseNullTime parses the given time or panics.

func ParseNullTime

func ParseNullTime(text string) (NullTime, error)

ParseNullTime tries to parse the given time.

func (NullTime) Equals

func (t NullTime) Equals(other NullTime) bool

Equals returns true if this Time and the given Time are equal. If they are both null it will return true.

func (NullTime) MarshalJSON

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

MarshalJSON implements the JSON Marshaler interface. Encodes to hh:mm:ss and omits the seconds if 0. Encodes to null if null.

func (NullTime) MarshalText

func (t NullTime) MarshalText() (text []byte, err error)

MarshalText implements the encoding TextMarshaler interface. Encodes to hh:mm:ss and omits the seconds if 0. Encodes to an empty string if null.

func (*NullTime) Scan

func (t *NullTime) Scan(src interface{}) error

Scan implements the driver Scanner interface.

func (NullTime) String

func (t NullTime) String() string

String returns a string representation of this Time.

func (*NullTime) UnmarshalJSON

func (t *NullTime) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the JSON Unmarshaler interface. Empty strings and "null" will be considered null.

func (*NullTime) UnmarshalText

func (t *NullTime) UnmarshalText(text []byte) error

UnmarshalText implements the encoding TextUnmarshaler interface. Empty strings and "null" will be considered null.

func (NullTime) Value

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

Value implements the driver Valuer interface.

type Time

type Time struct {
	Hours   int
	Minutes int
	Seconds int
}

Time represents an SQL TIME value.

func MustParseTime

func MustParseTime(text string) Time

MustParseTime parses the given time or panics.

func ParseTime

func ParseTime(text string) (Time, error)

ParseTime tries to parse the given time.

func (Time) Equals

func (t Time) Equals(other Time) bool

Equals returns true if this Time and the given Time are equal. If they are both null it will return true.

func (Time) MarshalText

func (t Time) MarshalText() (text []byte, err error)

MarshalText implements the encoding TextMarshaler interface. Encodes to hh:mm:ss and omits the seconds if 0.

func (*Time) Scan

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

Scan implements the driver Scanner interface.

func (Time) String

func (t Time) String() string

String returns a string representation of this Time.

func (*Time) UnmarshalText

func (t *Time) UnmarshalText(text []byte) error

UnmarshalText implements the encoding TextUnmarshaler interface.

func (Time) Value

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

Value implements the driver Valuer interface.

Jump to

Keyboard shortcuts

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