Documentation
¶
Index ¶
- Constants
- func Add(now time.Time, ivs ...Interval) time.Time
- func Begin(now time.Time, w Whole) time.Time
- func End(now time.Time, w Whole) time.Time
- func Next(now time.Time, w Whole) time.Time
- func Preview(now time.Time, w Whole) time.Time
- func Truncate(now time.Time, w Whole) time.Time
- type Allow
- type Block
- type Blocks
- type Duration
- type Interval
- type Iterator
- type IteratorType
- type TimeRange
- func (m TimeRange) Add(ivs Interval) TimeRange
- func (m TimeRange) After(time time.Time) bool
- func (m TimeRange) Before(time time.Time) bool
- func (m TimeRange) Begin() time.Time
- func (m TimeRange) Contains(time time.Time) bool
- func (m TimeRange) DayIndex() int
- func (m TimeRange) Duration() time.Duration
- func (m TimeRange) Empty() bool
- func (m TimeRange) End() time.Time
- func (m TimeRange) Equal(other TimeRange) bool
- func (m TimeRange) Format(format string) string
- func (m TimeRange) Head(iv Whole) (head, body TimeRange)
- func (m TimeRange) In(o TimeRange) bool
- func (m TimeRange) IsZero() bool
- func (m TimeRange) Iterator(iv Interval) *Iterator
- func (m TimeRange) Larger(o TimeRange) bool
- func (m TimeRange) Move(interval Interval) TimeRange
- func (m TimeRange) Size() (days int, duration time.Duration)
- func (m TimeRange) Smaller(o TimeRange) bool
- func (m TimeRange) Split(iv Interval) Blocks
- func (m TimeRange) String() string
- func (m TimeRange) Sub(ivs Interval) TimeRange
- func (m TimeRange) Tail(iv Whole) (tail, body TimeRange)
- func (m TimeRange) Time() (b, e time.Time)
- func (m TimeRange) Trim(iv Whole) TimeRange
- func (m TimeRange) TrimLeft(iv Whole) TimeRange
- func (m TimeRange) TrimRight(iv Whole) TimeRange
- func (m TimeRange) Truncate(iv Whole) (head, tail, body TimeRange)
- type Whole
- type WholeInterval
Constants ¶
View Source
const ( //时间点向未来方向移动 AllowForward Allow = 0 //时间点向历史方向移动 AllowRevert = 1 //保持原状态,不移动时间点 AllowStop = 2 )
View Source
const ( Second second = 1 Minute minute = 1 Hour hour = 1 Day day = 1 Month month = 1 Year year = 1 Week week = 1 )
View Source
const (
Today today = 1
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Interval ¶
type Interval interface {
//将时间点移动一个步长
//移动方向由NextAllow()函数决定
//AllowForward:
//+-----------+-----------+-----------+
// * --> ^
//
//AllowRevert:
//+-----------+-----------+-----------+
// ^ <-- *
//
//
//AllowStop:
//+-----------+-----------+-----------+
// *
// ^
AddTo(now time.Time) time.Time
//时间点在数轴上的移动方向
Allow() Allow
}
带移动方向时间间隔,时间点按照间隔步长在时间轴上进行移动
type Iterator ¶
type Iterator struct {
Current Block
// contains filtered or unexported fields
}
func NewIterator ¶
type IteratorType ¶
type IteratorType int
type Whole ¶
type Whole interface {
//将时间点移动到下一个整点
//12:00 12:01 12:02 12:03
// +-----------+-----------+-----------+
// * --> ^
Next(now time.Time) time.Time
//将时间点移动到当前个整点
//12:00 12:01 12:02 12:03
// +-----------+-----------+-----------+
// ^ <-- *
Current(now time.Time) time.Time
//将时间点移动到上一个整点
//12:00 12:01 12:02 12:03
// +-----------+-----------+-----------+
// ^ <-- *
Preview(now time.Time) time.Time
//判断时间点是否是整点时间
IsWhole(now time.Time) bool
}
可取整的时间间隔
type WholeInterval ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.