times

package
v0.0.0-...-843cdbd Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpeningHoursNoLimit = "no_limit" //不限
	OpeningHoursByWeek  = "week"     //按周设置
)

Variables

This section is empty.

Functions

func SameDay

func SameDay(a time.Time, b time.Time) bool

func SameMonth

func SameMonth(a time.Time, b time.Time) bool

func SameQuarter

func SameQuarter(a time.Time, b time.Time) bool

func SameWeek

func SameWeek(a time.Time, b time.Time) bool

func SameYear

func SameYear(a time.Time, b time.Time) bool

Types

type Between

type Between struct {
	Start time.Time `bson:"start" json:"start"`
	End   time.Time `bson:"end" json:"end"`
}

func (Between) Verify

func (btw Between) Verify() *errors.Error

type HM

type HM struct {
	Hour   int `bson:"h" json:"h"`
	Minute int `bson:"m" json:"m"`
}

HM 时间和分钟定义 HOUR MINUTE

func (HM) Key

func (hm HM) Key() string

func (HM) String

func (hm HM) String() string

func (HM) Verify

func (hm HM) Verify() *errors.Error

type HMBetween

type HMBetween struct {
	Start HM `bson:"start" json:"start"`
	End   HM `bson:"end" json:"end"`
}

func (HMBetween) Key

func (btw HMBetween) Key() string

Key 时间班次号,可用于排班

func (HMBetween) String

func (btw HMBetween) String() string

func (HMBetween) Verify

func (btw HMBetween) Verify() *errors.Error

type OHByWeekSetting

type OHByWeekSetting struct {
	Exclude        []time.Weekday      `bson:"exclude" json:"exclude"`                 //排除日期
	DefaultSetting []HMBetween         `bson:"default_setting" json:"default_setting"` //默认设置
	SpecialSetting map[int][]HMBetween `bson:"special_setting" json:"special_setting"` //特殊指定
}

func (OHByWeekSetting) GetOpening

func (ohw OHByWeekSetting) GetOpening(dt time.Time) (bool, OHItem)

func (OHByWeekSetting) Next

func (ohw OHByWeekSetting) Next(benchmark time.Time, size int) []OHItem

func (OHByWeekSetting) Verify

func (ohw OHByWeekSetting) Verify() *errors.Error

type OHItem

type OHItem struct {
	Date    time.Time   `bson:"date" json:"date"`       //对应日期
	Opening []HMBetween `bson:"opening" json:"opening"` //营业的时间
}

type OHNoLimitSetting

type OHNoLimitSetting struct{}

func (OHNoLimitSetting) GetOpening

func (ohl OHNoLimitSetting) GetOpening(dt time.Time) (bool, OHItem)

func (OHNoLimitSetting) Next

func (ohl OHNoLimitSetting) Next(benchmark time.Time, size int) []OHItem

func (OHNoLimitSetting) Verify

func (ohl OHNoLimitSetting) Verify() *errors.Error

type OHSetting

type OHSetting interface {
	Verify() *errors.Error                       //进行校验
	GetOpening(dt time.Time) (bool, OHItem)      //某天可用的营业时间
	Next(benchmark time.Time, size int) []OHItem //基于参考时间获取接下来的size个营业时间
}

type OpeningHours

type OpeningHours struct {
	Mode        string           `bson:"mode" json:"mode"`                 //设置模式
	WeekSetting *OHByWeekSetting `bson:"week_setting" json:"week_setting"` //基于周设置
}

func (OpeningHours) GetOpening

func (oh OpeningHours) GetOpening(dt time.Time) (bool, OHItem)

func (OpeningHours) Next

func (oh OpeningHours) Next(benchmark time.Time, size int) []OHItem

func (OpeningHours) Verify

func (oh OpeningHours) Verify() *errors.Error

Jump to

Keyboard shortcuts

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