Documentation ¶
Index ¶
- func HolidaysBase(t *Tart) error
- type Config
- type Relation
- type RelativeFunc
- type Tart
- func (t *Tart) Duration(in string) time.Duration
- func (t *Tart) Establish(tt time.Time)
- func (t *Tart) Get(in string) time.Time
- func (r Tart) GetRelation(k string) Relation
- func (t *Tart) Set(k, v string) error
- func (r Tart) SetBatch(in ...map[string]Relation) error
- func (r Tart) SetDirect(k string, v time.Time) error
- func (r Tart) SetFloat(k string, v float64) error
- func (r Tart) SetParsedDate(k, v string) error
- func (r Tart) SetRelation(k string, v Relation) error
- type TimeFunc
- func Any(t *Tart) TimeFunc
- func EOD(t *Tart) TimeFunc
- func EOM(t *Tart) TimeFunc
- func EOQ(t *Tart) TimeFunc
- func EOW(t *Tart) TimeFunc
- func EOWW(t *Tart) TimeFunc
- func EOY(t *Tart) TimeFunc
- func Now(t *Tart) TimeFunc
- func SOCM(t *Tart) TimeFunc
- func SOCW(t *Tart) TimeFunc
- func SOM(t *Tart) TimeFunc
- func SOQ(t *Tart) TimeFunc
- func SOW(t *Tart) TimeFunc
- func SOWW(t *Tart) TimeFunc
- func SOY(t *Tart) TimeFunc
- func Today(t *Tart) TimeFunc
- func Tomorrow(t *Tart) TimeFunc
- func Whenever(t *Tart) TimeFunc
- func Yesterday(t *Tart) TimeFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Relation ¶
Relation ...
func NominalDay ¶
NominalDay returns a Relation. The subsequent TimeFunc returned generates local date for the specified day(monday, tuesday, etc), after today, with time 00:00:00.
func NominalMonth ¶
NominalMonth returns a RelativeFunc returning a subsequent TimeFunc for local date for the specified month(january, february, etc), 1st day, with time 00:00:00.
type Tart ¶
Tart is a a struct encapsulating functionality related to a specific, embedded time.Time instance. An acronym for "time and relative time(in time)".
func (*Tart) Duration ¶
Duration returns the duration of the modifier of a parsed directive in relation to the tart time instance. e.g. ">7d>7d>7d+1h!" ==
">7d>7d>7d+1h" == ">7d>7d>7d+1h!<any relation>" == "505h" == (time.Duration) 505h0m0s
func (*Tart) Establish ¶
Establish sets the time of the instance to the provided time. This forces a reset to align the instance to the new time setting all relative funcs to defaults, removing cached time funcs, and erasing any set associations.
func (*Tart) Get ¶
Get attempts to return the time of the provided directive from the Tart instance.
A directive is a string of the form `modifiers ! point in time` where:
Modifiers are one or more signs followed by duration information:
'>' = shift forward '<' = shift backward '+' = iter next '-' = iter last 'iter' and 'shift' are functionally equivalent currently, use depending on your preference and need
Modifiers stack. Modifiers are collected by type. Duration is applied left wise to freestanding modifiers taking duration information.
e.g. ">>>>>>1h" = shift forward 6 hours "<1d<2d<<<<3d" = shift backward 15 days "+++++1h" = iter forward 5 hours "------1h" = iter back 6 hours "--3h>3h" = iter back 6 hours, shifted ahead 3 hours
Point in time is an exclamation point optionally followed by a string. Point may be a defined keyword relation or a date construction of some form. When not followed by a string, '!' means the tart instance fixed time. When not modified, the dot may be omitted, i.e absence of a concrete dot is indicative of a statement of point with no modification. A null string is equivalent to single point("" == "!")
e.g.' "!july 4 1776" = time of july 4, 1776 "!tuesday" = next tuesday "!eoq" = end of quarter "!later" = later
Construction of a directive is dependent on the output you desire. Common use is shifting time forward or backward, iteration from a specific point, and retrieving a specific point in time from a general specification. Order of application is to establish a point in time, iterate, then shift.
Examples:
`>>>1h.` = 3 hours forward from the tart instance time `<<<1h.` = 3 hours backward from the tart instance time `>>1h!tuesday` = 2 hours forward from next tuesday relative to the tart instance time `<<1h!tuesday` = 2 hours backward from next tuesday relative to the tart instance time `->>1h!tuesday` = 2 hours forward from last tuesday relative to the tart instance time `++<<1h!tuesday` = 2nd tuesday from now shifted back 2 hours `>>>>>1y!` = 5 years from now (where now is tart instance time) `+++++!` = 5 years from now (where now is tart instance time) `>>>>>1y!tuesday` = 5 years from next tuesday `<<<<<1y!oct 31 2025` = now, if today is oct 31 2020 `>.tuesday`, `!tuesday` = next tuesday, relative to the tart instance time `<!tuesday` = last tuesday, relative to the tart instance time `>>>1w!tuesday`, `>>>!tuesday` = 3rd tuesday from tart instance time `<<<!july 4 2006` = july 4th 2003 `+!july 4`, `!july 4` = the next july 4th `+!christmas`, `!christmas` = the next christmas (where christmas is defined on the tart instance) `!october 31 1927` = october 31 1927 `!october 31` = the next instance of october 31 `tomorrow`,`!tomorrow` = time tomorrow, relative to today
Unique directives are stored by key and reused within the scope of use.
type TimeFunc ¶
TimeFunc ...
func EOD ¶
EOD returns TimeFunc for "eod" where end of day is current local date, with time 23:59:59.
func EOM ¶
EOM returns TimeFunc providing local date for the last day of the current month, with time 23:59:59.
func EOQ ¶
EOQ returns TimeFunc providing local date for the end of the current quarter (March, June, September, December), last day of the month, with time 23:59:59.
func EOW ¶
EOW returns TimeFunc for local date for the end of the week, Saturday night, with time 00:00:00.
func EOWW ¶
EOWW returns TimeFunc for local date for the end of the work week, Friday night, with time 23:59:59.
func EOY ¶
EOY returns TimeFunc providing local date for this year, December 31st, with time 00:00:00.
func SOCM ¶
SOCM returns TimeFunc for local date for the 1st day of the current month, with time 00:00:00.
func SOM ¶
SOM returns TimeFunc providing local date for the 1st day of the next month, with time 00:00:00.
func SOQ ¶
SOQ returns TimeFunc providing local date for the start of the next quarter (January, April, July, October), 1st, with time 00:00:00.
func SOWW ¶
SOWW returns TimeFunc providing local date for the start of the work week, next Monday, with time 00:00:00.
func SOY ¶
SOY returns TimeFunc providing local date for the next year, January 1st, with time 00:00:00.
func Tomorrow ¶
Tomorrow returns TimeFunc for "tomorrow" as local date for tomorrow, with time 00:00:00. Same as sod(start of day).