Documentation ¶
Index ¶
- Constants
- func DayAdd(t time.Time, days int) time.Time
- func DayEnd(t time.Time) time.Time
- func DayStart(t time.Time) time.Time
- func FixAlarmID(id string) string
- func FixTaskID(id string) string
- func GetDaysOfMonth(year int, month int) int
- func HourAdd(t time.Time, hours int) time.Time
- func HourEnd(t time.Time) time.Time
- func HourStart(t time.Time) time.Time
- func IsWorkDay(t time.Time) bool
- func LunarGetDaysOfMonth(year int, month int) int
- func LunarMonthAdd(t time.Time, months int) time.Time
- func LunarMonthEnd(t time.Time) time.Time
- func LunarMonthEndAdd(t time.Time, months int) time.Time
- func LunarMonthStart(t time.Time) time.Time
- func LunarToDateTime(year, month, day, hour, minute, second int) time.Time
- func LunarToDateTimeAndNextDay(year, month, day, hour, minute, second int, days int) time.Time
- func LunarToDateTimeAndNextMonth(lunarYear, lunarMonth, lunarDay, hour, minute, second int, months int) (t time.Time, err error)
- func LunarToDateTimeAndNextYear(lunarYear, lunarMonth, lunarDay, hour, minute, second int, years int) (t time.Time, err error)
- func LunarYMD(t time.Time) (year, month, day int)
- func LunarYearBeginAdd(t time.Time, years int) time.Time
- func LunarYearEnd(t time.Time) time.Time
- func LunarYearEndAdd(t time.Time, years int) time.Time
- func LunarYearStart(t time.Time) time.Time
- func MinuteAdd(t time.Time, minutes int) time.Time
- func MinuteEnd(t time.Time) time.Time
- func MinuteStart(t time.Time) time.Time
- func MonthAdd(t time.Time, months int) time.Time
- func MonthEnd(t time.Time) time.Time
- func MonthStart(t time.Time) time.Time
- func ParsePreOnID(id string) string
- func ToDateTime(year, month, day, hour, minute, second int, location *time.Location) time.Time
- func WeekAdd(t time.Time, weeks int) time.Time
- func WeekEnd(t time.Time) time.Time
- func WeekIndexInMonth(t time.Time) int
- func WeekStart(t time.Time) time.Time
- func YearAdd(t time.Time, years int) time.Time
- func YearEnd(t time.Time) time.Time
- func YearStart(t time.Time) time.Time
- type Alarm
- func (a *Alarm) GenRecycleData() (av *AlarmValue, timeAt time.Time, rd *ShowItem, show, alarm bool, err error)
- func (a *Alarm) GenRecycleDataEx(timeNow, timeLastAt time.Time) (av *AlarmValue, timeAt time.Time, rd *ShowItem, show, alarm bool, err error)
- func (a *Alarm) Validate() (av *AlarmValue, err error)
- type AlarmManager
- type AlarmValue
- type BizTaskTimer
- type Callback
- type D
- type ShowInfo
- type ShowInfoListChangeObserver
- type ShowItem
- type ShowList
- type Task
- type TaskManager
- type TaskTimer
- type TimeType
- type VOTaskType
- type ValidRange
- type ValidRanges
- type ValidTime
Constants ¶
View Source
const ( TaskIDPre = "T" AlarmIDPre = "A" )
Variables ¶
This section is empty.
Functions ¶
func FixAlarmID ¶
func GetDaysOfMonth ¶
func LunarGetDaysOfMonth ¶
func LunarToDateTime ¶
func ParsePreOnID ¶
func ToDateTime ¶
func WeekIndexInMonth ¶
Types ¶
type Alarm ¶
type Alarm struct { ID string `yaml:"ID" json:"id,omitempty"` AType TimeType `yaml:"AType,omitempty" json:"a_type,omitempty"` Text string `yaml:"Text" json:"text,omitempty"` Value string `yaml:"Value,omitempty" json:"value,omitempty"` // @see AlarmValue TimeZone int `yaml:"TimeZone,omitempty" json:"timeZone,omitempty"` ValidTime *ValidTime `yaml:"ValidRanges,omitempty" json:"valid_time,omitempty"` EarlyShowMinute int `yaml:"EarlyShowMinute,omitempty" json:"early_show_minute,omitempty"` // // // TimeLastAt int64 `yaml:"TimeLastAt,omitempty" json:"time_last_at,omitempty"` // ? }
func (*Alarm) GenRecycleData ¶
func (*Alarm) GenRecycleDataEx ¶
func (a *Alarm) GenRecycleDataEx(timeNow, timeLastAt time.Time) (av *AlarmValue, timeAt time.Time, rd *ShowItem, show, alarm bool, err error)
GenRecycleDataEx nolint: gocyclo
func (*Alarm) Validate ¶
func (a *Alarm) Validate() (av *AlarmValue, err error)
type AlarmManager ¶
type AlarmManager interface { Add(alarm *Alarm) error Remove(id string) error Done(id string) error }
func NewAlarmManager ¶
func NewAlarmManager(storage kv.Storage, timer BizTaskTimer, taskList ShowList, logger l.Wrapper) AlarmManager
type AlarmValue ¶
type AlarmValue struct { Lunar bool Year int Month int Day int Week int Hour int Minute int Second int }
func ParseAlarmValue ¶
func ParseAlarmValue(value string, aType TimeType) (av *AlarmValue, err error)
func (*AlarmValue) StringNoNowTime ¶
func (av *AlarmValue) StringNoNowTime(aType TimeType) (bool, string)
func (*AlarmValue) Valid ¶
func (av *AlarmValue) Valid(aType TimeType) bool
type BizTaskTimer ¶
type BizTaskTimer interface { AddTimer(at time.Time, data *ShowItem) error SetCallback(idPre string, cb Callback) }
BizTaskTimer 危险 确保 idPre 不重复 且 ShowItem 的 ID 符合规则
func NewBizTimer ¶
func NewBizTimer(timer TaskTimer) BizTaskTimer
type ShowInfo ¶
type ShowInfo struct { ID string `json:"id"` Value string `json:"value"` /* once task: recycle task: start - end alarm: future/outdate */ SubTitle string `json:"sub_title"` AlarmFlag bool `json:"alarm_flag,omitempty"` AlarmAt time.Time `json:"alarm_at,omitempty"` // // // VOTaskType VOTaskType `json:"vo_task_type"` // // // NotifyID string `json:"notify_id,omitempty"` // LeftTimeS string `json:"left_time_s"` }
type ShowList ¶
type ShowList interface { SetOb(ob ShowInfoListChangeObserver) error Add(taskInfo *ShowInfo) error // 如果存在,也不要返回错误 Get(taskID string) (taskInfo *ShowInfo, err error) Remove(taskID string) error // 如果不存在,也不要返回错误 GetList() ([]*ShowInfo, error) }
func NewShowList ¶
func NewShowList(fileName string, ob ShowInfoListChangeObserver) ShowList
type Task ¶
type Task struct { ID string `yaml:"ID" json:"id,omitempty"` TType TimeType `yaml:"TType,omitempty" json:"t_type,omitempty"` LunarFlag bool `yaml:"lunar_flag" json:"lunar_flag"` Text string `yaml:"Text" json:"text,omitempty"` Value int `yaml:"Value,omitempty" json:"value,omitempty"` Auto bool `yaml:"Auto,omitempty" json:"auto,omitempty"` TimeZone int `yaml:"TimeZone,omitempty" json:"time_zone,omitempty"` ValidTime *ValidTime `yaml:"ValidRanges,omitempty" json:"valid_time,omitempty"` }
func (*Task) GenRecycleData ¶
func (*Task) GenRecycleDataEx ¶
type TaskManager ¶
type TaskManager interface { Add(task *Task) error Remove(taskID string) error Done(taskID string) error TaskDone(taskID string) }
func NewTaskManager ¶
func NewTaskManager(storage kv.Storage, timer BizTaskTimer, taskList ShowList, logger l.Wrapper) TaskManager
type TaskTimer ¶
type TaskTimer interface { Start() AddTimer(at time.Time, data *ShowItem) error SetCallback(cb Callback) List() (items []D, err error) }
func NewTaskTimer ¶
type VOTaskType ¶
type VOTaskType int
const ( VOTaskTypeUnknown VOTaskType = iota VOTaskTypeTask VOTaskTypeAlarm )
type ValidRange ¶
type ValidRanges ¶
type ValidRanges struct {
ValidRanges []ValidRange `yaml:"ValidRanges" json:"valid_ranges,omitempty"`
}
func (*ValidRanges) IsValid ¶
func (o *ValidRanges) IsValid(value int) bool
type ValidTime ¶
type ValidTime struct { ValidMonthsInYear *ValidRanges `yaml:"ValidMonthsInYear,omitempty" json:"valid_months_in_year,omitempty"` ValidWeeksInMonth *ValidRanges `yaml:"ValidWeeksInMonth,omitempty" json:"valid_weeks_in_month,omitempty"` ValidDaysInMonth *ValidRanges `yaml:"ValidDaysInMonth,omitempty" json:"valid_days_in_month,omitempty"` ValidDaysInWeek *ValidRanges `yaml:"ValidDaysInWeek,omitempty" json:"valid_days_in_week,omitempty"` ValidHoursInDay *ValidRanges `yaml:"ValidHoursInDay,omitempty" json:"valid_hours_in_day,omitempty"` }
func (*ValidTime) FindAfterTime ¶
Click to show internal directories.
Click to hide internal directories.