libtime

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 3 Imported by: 0

README

libtime

Usage

import (
    "github.com/Delisa-sama/libtime"
)

type Shop struct {
    Open  libtime.Time
    Close libtime.Time
}

func main() {
    var s Shop
    data := []byte(`{"open":"09:00-03:00","close":"09:00-03:00"}`)
    if err := json.Unmarshal(data, &s); err != nil {
    	// handle unmarshaling error
    }
    now := time.Now()
    if s.Open.Before(now) && s.Close.After(now) {
    	// shop is open now
    }
}

Documentation

Index

Constants

View Source
const (
	HHMM           = "15:04"
	HHMMPostgre    = "15:04:05-07:00"
	ISO8601        = "15:04-07:00"
	ISO8601Postgre = "15:04:05-07"
)

Variables

View Source
var (
	ErrTimeParse = errors.New(`ErrTimeParse: should be a string formatted as "15:04"`)
	ErrTimeScan  = errors.New(`ErrTimeScan: source must be []byte`)
)

Functions

This section is empty.

Types

type Time

type Time struct {
	time.Time
}

func (Time) MarshalJSON

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

func (*Time) Scan

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

func (*Time) UnmarshalJSON

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

func (Time) Value

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

Jump to

Keyboard shortcuts

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