Documentation
¶
Overview ¶
TODO: find a home for this
Index ¶
- func DateAndTimestampToGotime(date Date, ts Timestamp, timezone *time.Location) time.Time
- func GoalForRange(goal Goal, start, end time.Time) time.Duration
- type ByName
- type ByStartConsideringDuration
- type Category
- type CategoryName
- type Date
- func (d Date) Backward(by int) Date
- func (d Date) DaysUntil(other Date) int
- func (d Date) Forward(by int) Date
- func (d Date) GetDayInMonth(index int) Date
- func (d Date) GetDayInWeek(index int) Date
- func (d Date) GetLastOfMonth() Date
- func (d Date) Is(t time.Time, timezone *time.Location) bool
- func (d Date) IsAfter(other Date) bool
- func (d Date) IsBefore(other Date) bool
- func (d Date) MonthBounds() (first Date, last Date)
- func (d Date) Next() Date
- func (d Date) Prev() Date
- func (d Date) String() string
- func (d Date) ToGotime(timezone *time.Location) time.Time
- func (d Date) ToWeekday(timezone *time.Location) time.Weekday
- func (d Date) Valid() bool
- func (d Date) WeekBounds() (monday Date, sunday Date)
- type DateAndTime
- type DateSlice
- type Event
- type EventID
- type EventList
- func (l *EventList) AddEvent(e *Event) error
- func (l *EventList) Clone() EventList
- func (l *EventList) Flatten(getCategoryPriority func(CategoryName) int)
- func (l *EventList) GetEventByID(id EventID) *Event
- func (l *EventList) GetNextEventAfter(t time.Time) *Event
- func (l *EventList) GetPrevEventBefore(t time.Time) *Event
- func (l *EventList) GetTimesheetEntry(matcher func(CategoryName) bool, getCategoryPriority func(CategoryName) int, ...) (*TimesheetEntry, error)
- func (l *EventList) MoveSingleEventBy(event *Event, duration time.Duration, snapMod time.Duration)
- func (l *EventList) MoveSingleEventTo(event *Event, newStart time.Time)
- func (l *EventList) RemoveEvent(event *Event) error
- func (l *EventList) ResizeBy(event *Event, delta time.Duration) error
- func (l *EventList) ResizeTo(event *Event, newEnd time.Time) error
- func (l *EventList) SplitEvent(originalEvent *Event, timestamp time.Time) error
- func (l *EventList) SumUpByCategory(getCategoryPriority func(CategoryName) int) map[CategoryName]time.Duration
- func (l *EventList) UpdateEventOrder()
- type Goal
- type RangedGoal
- type ReadableTask
- type SunTimes
- type SuntimesProvider
- type Task
- func (t *Task) Equal(t2 ReadableTask) bool
- func (t *Task) GetCategory() CategoryName
- func (t *Task) GetDeadline() *time.Time
- func (t *Task) GetDuration() *time.Duration
- func (t *Task) GetID() TaskID
- func (t *Task) GetName() string
- func (t *Task) GetSubtasks() []ReadableTask
- func (t *Task) ToEvent(startTime time.Time, namePrefix string) []*Event
- type TaskID
- type TasksByDeadline
- type TimeOffset
- type TimesheetEntry
- type Timestamp
- func (t1 Timestamp) DurationInMinutesUntil(t2 Timestamp) int
- func (t1 Timestamp) DurationUntil(t2 Timestamp) time.Duration
- func (a Timestamp) IsAfter(b Timestamp) bool
- func (a Timestamp) IsBefore(b Timestamp) bool
- func (t Timestamp) Legal() bool
- func (t Timestamp) Offset(o TimeOffset) Timestamp
- func (t Timestamp) OffsetMinutes(minutes int) Timestamp
- func (t Timestamp) Snap(minutesModulus int) Timestamp
- func (a Timestamp) ToString() string
- func (t Timestamp) Truncate(durationMinutes uint) Timestamp
- type WorkweekGoal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DateAndTimestampToGotime ¶ added in v0.10.0
DateAndTimestampToGotime returns a time.Time object from a given date and a given timestamp.
Types ¶
type ByStartConsideringDuration ¶
type ByStartConsideringDuration []*Event
...
func (ByStartConsideringDuration) Len ¶
func (a ByStartConsideringDuration) Len() int
func (ByStartConsideringDuration) Less ¶
func (a ByStartConsideringDuration) Less(i, j int) bool
func (ByStartConsideringDuration) Swap ¶
func (a ByStartConsideringDuration) Swap(i, j int)
type CategoryName ¶ added in v0.10.0
type CategoryName string
type Date ¶
Date represents a date, i.e. a year, month and day.
func DateFromString ¶ added in v0.10.0
DateFromString creates a date from a string in the format "YYYY-MM-DD".
func (Date) DaysUntil ¶
DaysUntil returns the number of days from a date A until a date B is reached. (e.g. from 2021-12-14 until 2021-12-19 -> 5 days) expects `other` not to be before `d`
func (Date) GetDayInMonth ¶
GetDayInMonth returns the indexed day in the month of the receiver.
Note that indexing 0 will return the first of the month.
func (Date) GetDayInWeek ¶
GetDayInWeek returns the date that is on the weekday for the given index in the week the receiver is in.
Index here means that 0 is Monday, 6 is Sunday.
func (Date) GetLastOfMonth ¶
GetLastOfMonth returns the last date of the month of the receiver.
func (Date) MonthBounds ¶
MonthBounds returns the first and last date of the month the receiver is in.
func (Date) String ¶ added in v0.10.0
String returns the date as a string in the format "YYYY-MM-DD".
func (Date) ToGotime ¶
ToGotime returns the date as a time.Time with the time set to midnight (at the start of the day).
func (Date) Valid ¶
Valid returns whether the date is valid. A date such as the 31st of February is invalid, for example.
func (Date) WeekBounds ¶ added in v0.10.0
WeekBounds returns the monday and sunday of the week the receiver is in.
type DateAndTime ¶ added in v0.10.0
DateAndTime represents a date and a time, a datetime.
type Event ¶
type Event struct {
ID EventID `dpedit:",ignore"`
Name string `dpedit:"name"`
Category CategoryName `dpedit:"category"`
Start time.Time `dpedit:",ignore"`
End time.Time `dpedit:",ignore"`
}
...
func (*Event) IsContainedIn ¶
Whether one event A contains another B, i.E. - B's start is _not before_ A's start and - B's end is _not after_ A's end
func (*Event) StartsDuring ¶
Whether one event B starts during another A.
type EventList ¶ added in v0.10.0
type EventList struct {
Events []*Event
}
EventList is a list of events I suppose.
func (*EventList) Flatten ¶ added in v0.10.0
func (l *EventList) Flatten(getCategoryPriority func(CategoryName) int)
Flatten "flattens" the events of a given day, i.E. ensures that no overlapping events exist. It does this by e.g. trimming one of two overlapping events or splitting a less prioritized event if it had a higher-priority event occur during it as shown here:
+-------+ +-------+
| a | | a | (`a` lower prio than `B`)
| +-----+ +-------+
| | B | ~~> | B |
| +-----+ +-------+
| | | a |
+-------+ +-------+
+-------+ +-------+
| a | | a | (`a` lower prio than `B`)
| +-----+ +-------+
| | B | ~~> | B |
+---| | | |
+-----+ +-------+
It modifies the input in-place.
func (*EventList) GetEventByID ¶ added in v0.10.0
func (*EventList) GetNextEventAfter ¶ added in v0.10.0
...
func (*EventList) GetPrevEventBefore ¶ added in v0.10.0
...
func (*EventList) GetTimesheetEntry ¶ added in v0.10.0
func (l *EventList) GetTimesheetEntry(matcher func(CategoryName) bool, getCategoryPriority func(CategoryName) int, date Date, timezone *time.Location) (*TimesheetEntry, error)
GetTimesheetEntry returns the TimesheetEntry for this day for a given category (e.g. "work").
func (*EventList) MoveSingleEventBy ¶ added in v0.10.0
...
func (*EventList) MoveSingleEventTo ¶ added in v0.10.0
func (*EventList) RemoveEvent ¶ added in v0.10.0
...
func (*EventList) SplitEvent ¶ added in v0.10.0
...
func (*EventList) SumUpByCategory ¶ added in v0.10.0
func (l *EventList) SumUpByCategory(getCategoryPriority func(CategoryName) int) map[CategoryName]time.Duration
Sum up the event durations of a given day per category. Time cannot be counted multiple times, so if multiple events overlap, only one of them can have the time of the overlap counted. The prioritization for this is according to category priority.
type Goal ¶
Goal defines a time goal. It can be queried, for any given date, what duration the goal requires.
type RangedGoal ¶
type RangedGoal struct {
Entries []rangedGoalEntry
}
RangedGoal is a Goal that is defined by any number of ranges and the expected duration for each.
func NewRangedGoalFromConfig ¶
func NewRangedGoalFromConfig(cfg []config.RangedGoal) (*RangedGoal, error)
NewRangedGoalFromConfig constructs a new RangedGoal from config data.
type ReadableTask ¶ added in v0.10.0
type SunTimes ¶
type SunTimes struct {
Rise, Set Timestamp
}
SunTimes represents the sunrise and sunset times of a date.
type SuntimesProvider ¶ added in v0.10.0
func (*SuntimesProvider) Get ¶ added in v0.10.0
func (p *SuntimesProvider) Get(d Date) SunTimes
GetSunTimes returns the sunrise and sunset times for the receiver-date at the given location. Warning: slow (TODO)
type Task ¶ added in v0.8.0
type Task struct {
ID TaskID `dpedit:",ignore"`
Name string `dpedit:"name"`
Category CategoryName `dpedit:"category"`
Duration *time.Duration `dpedit:"duration"`
Deadline *time.Time `dpedit:"deadline"`
Subtasks []*Task `dpedit:",ignore"`
}
A Task remains to be done (or dropped) but is not yet scheduled. It has a name and belongs to a category (by name); it can further have a duration (estimate), a deadline (due date) and subtasks.
func (*Task) Equal ¶ added in v0.10.0
func (t *Task) Equal(t2 ReadableTask) bool
func (*Task) GetCategory ¶ added in v0.10.0
func (t *Task) GetCategory() CategoryName
func (*Task) GetDeadline ¶ added in v0.10.0
func (*Task) GetDuration ¶ added in v0.10.0
func (*Task) GetSubtasks ¶ added in v0.10.0
func (t *Task) GetSubtasks() []ReadableTask
type TasksByDeadline ¶ added in v0.9.2
type TasksByDeadline []*Task
TasksByDeadline is a sort interface to stort tasks by their deadlines
func (TasksByDeadline) Len ¶ added in v0.9.2
func (a TasksByDeadline) Len() int
func (TasksByDeadline) Less ¶ added in v0.9.2
func (a TasksByDeadline) Less(i, j int) bool
func (TasksByDeadline) Swap ¶ added in v0.9.2
func (a TasksByDeadline) Swap(i, j int)
type TimeOffset ¶
type TimesheetEntry ¶ added in v0.9.0
A TimesheetEntry represents an entry in a common timesheet.
It defines a beginning (i.e. the time you clocked in), an end (i.e. the time you clocked out), and the total length of breaks taken between them.
func (*TimesheetEntry) IsEmpty ¶ added in v0.9.0
func (e *TimesheetEntry) IsEmpty() bool
IsEmpty is a helper to identify empty timesheet entries.
type Timestamp ¶
type Timestamp struct {
Hour, Minute int
}
func NewTimestamp ¶
func NewTimestampFromGotime ¶
func (Timestamp) DurationInMinutesUntil ¶
Returns the duration in minutes between to a given timestamp t2. Does not check that t2 is in fact later!
func (Timestamp) DurationUntil ¶ added in v0.7.8
Returns the duration (time.Duration) to a given timestamp t2. Does not check that t2 is in fact later!
func (Timestamp) Offset ¶
func (t Timestamp) Offset(o TimeOffset) Timestamp
Returns a timestamp offset by a given offset, which can be additive or subtractive. "Loops around", meaning offsetting 0:10 by -1 hour results in 23:10, offsetting 23:10 by +1 hour results in 0:10.
func (Timestamp) OffsetMinutes ¶
type WorkweekGoal ¶
type WorkweekGoal struct {
Monday time.Duration
Tuesday time.Duration
Wednesday time.Duration
Thursday time.Duration
Friday time.Duration
Saturday time.Duration
Sunday time.Duration
}
WorkweekGoal is a goal that defines the duration per day of the week.
func NewWorkweekGoalFromConfig ¶
func NewWorkweekGoalFromConfig(cfg config.WorkweekGoal) (*WorkweekGoal, error)
NewWorkweekGoalFromConfig constructs a new WorkweekGoal from config data.