mdate

package module
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 8 Imported by: 0

README

date-go

Documentation

Index

Constants

View Source
const (
	ErrorInvalidDateSpan  merrors.ErrorType = "invalid_date_span"
	ErrorNoOverlapToClamp merrors.ErrorType = "no_overlap_to_clamp"
)
View Source
const (
	ErrorInvalidMonth merrors.ErrorType = "invalidMonth"
)

Variables

This section is empty.

Functions

func InvalidDateSpan

func InvalidDateSpan() merrors.CommonError

func InvalidMonth

func InvalidMonth() merrors.CommonError

func NoOverlapToClamp

func NoOverlapToClamp() merrors.CommonError

Types

type Date

type Date struct {
	time.Time
}

func GetToday

func GetToday() Date

func MustDateFromStr

func MustDateFromStr(str string) Date

func NewDate

func NewDate(year int, month time.Month, day int) Date

func NewDateFromStr

func NewDateFromStr(str string) (Date, error)

func NewDateFromStrWithFormat

func NewDateFromStrWithFormat(format string, str string) (Date, error)

func NewDateFromUnix

func NewDateFromUnix(unixTime int64) Date

func (Date) DateDiff

func (d Date) DateDiff(other Date) int

func (Date) IsEarlier

func (d Date) IsEarlier(other Date) bool

func (Date) IsEarlierEq

func (d Date) IsEarlierEq(other Date) bool

func (Date) IsEqual

func (d Date) IsEqual(other Date) bool

func (Date) IsLater

func (d Date) IsLater(other Date) bool

func (Date) IsLaterEq

func (d Date) IsLaterEq(other Date) bool

func (Date) IsNextDay

func (d Date) IsNextDay(other Date) bool

func (Date) JapanFiscalYear

func (d Date) JapanFiscalYear() JapanFiscalYear

func (Date) MarshalJSON

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

func (Date) MarshalText

func (d Date) MarshalText() (text []byte, err error)

func (Date) MinusNDay

func (d Date) MinusNDay(n int) Date

func (Date) Month

func (d Date) Month() Month

func (Date) PlusNDay

func (d Date) PlusNDay(n int) Date

func (*Date) Scan

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

for sql driver

func (Date) String

func (d Date) String() string

func (Date) StringWithFormat

func (d Date) StringWithFormat(format string) string

func (*Date) UnmarshalJSON

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

func (Date) Value

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

for sql driver

func (Date) Year

func (d Date) Year() Year

func (Date) YearMonth

func (d Date) YearMonth() YearMonth

type DateSpan

type DateSpan struct {
	StartDate Date `json:"startDate"`
	EndDate   Date `json:"endDate"`
}

func MustDateSpan

func MustDateSpan(startDate Date, endDate Date) DateSpan

func NewDateSpan

func NewDateSpan(startDate Date, endDate Date) (DateSpan, error)

func (DateSpan) ClampDateSpan

func (s DateSpan) ClampDateSpan(other DateSpan) (DateSpan, error)

ClampDateSpan 重複している期間を取り出す

func (DateSpan) GetDateList

func (s DateSpan) GetDateList() Dates

func (DateSpan) IncludesDate

func (s DateSpan) IncludesDate(date Date) bool

func (DateSpan) IsContinuous

func (s DateSpan) IsContinuous(other DateSpan) bool

func (DateSpan) IsOverlapping

func (s DateSpan) IsOverlapping(other DateSpan) bool

func (DateSpan) OverlappingYearMonth

func (s DateSpan) OverlappingYearMonth() YearMonths

type DateSpans

type DateSpans []DateSpan

func (DateSpans) GetDateList

func (s DateSpans) GetDateList() Dates

func (DateSpans) Len

func (s DateSpans) Len() int

func (DateSpans) Less

func (s DateSpans) Less(i, j int) bool

StartDate順に並びかえ

func (DateSpans) Merge

func (s DateSpans) Merge() DateSpans

重複除去してマージ

func (DateSpans) Swap

func (s DateSpans) Swap(i, j int)

type DateSpansSlice

type DateSpansSlice []DateSpans

func (DateSpansSlice) Merge

func (s DateSpansSlice) Merge() DateSpans

type Dates

type Dates []Date

func (Dates) Len

func (d Dates) Len() int

func (Dates) Less

func (d Dates) Less(i, j int) bool

func (Dates) StringArray

func (dates Dates) StringArray() []string

func (Dates) Swap

func (d Dates) Swap(i, j int)

type JapanFiscalYear

type JapanFiscalYear int

日本の年度を表すデータ型

type Month

type Month int
const (
	January   Month = 1
	February  Month = 2
	March     Month = 3
	April     Month = 4
	May       Month = 5
	June      Month = 6
	July      Month = 7
	August    Month = 8
	September Month = 9
	October   Month = 10
	November  Month = 11
	December  Month = 12
)

func NewMonth

func NewMonth(m int) (Month, error)

func (Month) String

func (month Month) String() string

type Year

type Year int

func NewYear

func NewYear(y int) Year

type YearMonth

type YearMonth struct {
	Year  Year  `json:"year"`
	Month Month `json:"month"`
}

func NewYearMonth

func NewYearMonth(year Year, month Month) YearMonth

func NewYearMonthFromStr

func NewYearMonthFromStr(str string) (YearMonth, error)

func (YearMonth) EndDate

func (ym YearMonth) EndDate() Date

func (YearMonth) IsAfter

func (ym YearMonth) IsAfter(another YearMonth) bool

func (YearMonth) NextMonth

func (ym YearMonth) NextMonth() YearMonth

func (YearMonth) StartDate

func (ym YearMonth) StartDate() Date

func (YearMonth) String

func (ym YearMonth) String() string

type YearMonths

type YearMonths []YearMonth

Jump to

Keyboard shortcuts

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