local

package module
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package local provides local date and datetime types for GORM and SQLight.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Date

type Date struct {
	// contains filtered or unexported fields
}

func FromString

func FromString(str string) (Date, error)

func NewDate

func NewDate(year, month, day int) Date

NewDate returns a new date.Date.

func NowDate

func NowDate() Date

NowDate returns a new date.Date with the current date.

func (Date) AddDays

func (l Date) AddDays(days int) Date

AddDays returns a new date.Date with the specified number of days added to l.

func (Date) AddMonths

func (l Date) AddMonths(months int) Date

AddMonths returns a new date.Date with the specified number of months added to l.

func (Date) AddYears

func (l Date) AddYears(years int) Date

AddYears returns a new date.Date with the specified number of years added to l.

func (Date) After

func (l Date) After(b Date) bool

After returns true if l is after b.

func (Date) Before

func (l Date) Before(b Date) bool

Before returns true if l is before b.

func (Date) Day

func (l Date) Day() int

Day returns the day of the month specified by l.

func (Date) Equal

func (l Date) Equal(b Date) bool

Equal returns true if l and b are the same date.

func (Date) EqualMonth

func (l Date) EqualMonth(b Date) bool

EqualMonth returns true if l and b are the same month and year.

func (Date) EqualQuarter

func (l Date) EqualQuarter(b Date) bool

EqualQuarter returns true if l and b are the same quarter and year.

func (Date) EqualYear

func (l Date) EqualYear(b Date) bool

EqualYear returns true if l and b are the same year.

func (Date) GormDBDataType

func (Date) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType returns gorm DB data type based on the current using database.

func (Date) GormDataType

func (Date) GormDataType() string

GormDataType returns gorm common data type. This type is used for the field's column type.

func (Date) MarshalJSON

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

MarshalJSON implements json.Marshaler to convert Time to json serialization.

func (Date) MinusDays

func (l Date) MinusDays(days int) Date

MinusDays returns a new date.Date with the specified number of days subtracted from l.

func (Date) MinusMonths

func (l Date) MinusMonths(months int) Date

MinusMonths returns a new date.Date with the specified number of months subtracted from l.

func (Date) MinusYears

func (l Date) MinusYears(years int) Date

MinusYears returns a new date.Date with the specified number of years subtracted from l.

func (Date) Month

func (l Date) Month() int

Month returns the month specified by l.

func (Date) Quarter

func (l Date) Quarter() Date

Quarter returns the first day of the quarter of the year specified by l.

func (*Date) Scan

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

Scan implements sql.Scanner interface and scans value into Time,

func (Date) String

func (t Date) String() string

String implements fmt.Stringer interface.

func (*Date) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler to deserialize json data.

func (Date) Value

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

Value implements driver.Valuer interface and returns string format of Time.

func (Date) Year

func (l Date) Year() int

Year returns the year specified by l.

type Time

type Time struct {
	// contains filtered or unexported fields
}

func NewTime

func NewTime(year, month, day, hour, min, sec int) Time

NewTime returns a new date.Time.

func NowTime

func NowTime() Time

NowLocal returns a new local.Date with the current date.

func TimeFromString added in v0.6.1

func TimeFromString(s string) (Time, error)

TimeFromString returns a new local.Time from a string.

func (Time) Add added in v0.4.0

func (l Time) Add(d time.Duration) Time

Add returns a new local.Date with the specified duration added to l.

func (Time) AddDays

func (l Time) AddDays(days int) Time

AddDays returns a new local.Date with the specified number of days added to l.

func (Time) After

func (l Time) After(b Time) bool

After returns true if l is after b.

func (Time) Before

func (l Time) Before(b Time) bool

Before returns true if l is before b.

func (Time) GormDBDataType

func (Time) GormDBDataType(db *gorm.DB, field *schema.Field) string

GormDBDataType returns gorm DB data type based on the current using database.

func (Time) GormDataType

func (Time) GormDataType() string

GormDataType returns gorm common data type. This type is used for the field's column type.

func (Time) IsZero added in v0.6.0

func (t Time) IsZero() bool

IsZero reports whether t represents the zero time instant, January 1, year 1, 00:00:00 UTC.

func (Time) MarshalJSON

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

MarshalJSON implements json.Marshaler to convert Time to json serialization.

func (*Time) Scan

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

Scan implements sql.Scanner interface and scans value into Time,

func (Time) String

func (t Time) String() string

String implements fmt.Stringer interface.

func (Time) Sub added in v0.5.0

func (l Time) Sub(b Time) time.Duration

Sub returns the duration between l and b.

func (*Time) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler to deserialize json data.

func (Time) Value

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

Value implements driver.Valuer interface and returns string format of Time.

Jump to

Keyboard shortcuts

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