task

package
v0.0.0-...-4b6167c Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FOLDER_INBOX     = "INBOX"
	FOLDER_NEW       = "New"
	FOLDER_RECURRING = "Recurring"
	FOLDER_PLANNED   = "Planned"
	FOLDER_UNPLANNED = "Unplanned"

	QUOTE_PREFIX       = ">"
	PREVIOUS_SEPARATOR = "Previous version:"

	FIELD_SEPARATOR   = ":"
	SUBJECT_SEPARATOR = " - "

	FIELD_ID      = "id"
	FIELD_VERSION = "version"
	FIELD_ACTION  = "action"
	FIELD_PROJECT = "project"
	FIELD_DUE     = "due"
	FIELD_RECUR   = "recur"
)
View Source
const (
	DateFormat = "2006-01-02 (Monday)"
)

Variables

View Source
var (
	ErrMStoreError    = errors.New("mstore gave error response")
	ErrInvalidTask    = errors.New("invalid task")
	ErrInvalidMessage = errors.New("task contains invalid message")
)
View Source
var (
	ErrOutdatedTask       = errors.New("task is outdated")
	ErrTaskIsNotRecurring = errors.New("task is not recurring")
)

Functions

func FieldFromBody

func FieldFromBody(field, body string) (string, bool)

func FieldFromSubject

func FieldFromSubject(field, subject string) string

func ParseWeekday

func ParseWeekday(wd string) (time.Weekday, bool)

Types

type Biweekly

type Biweekly struct {
	Start   Date
	Weekday time.Weekday
}

func (Biweekly) RecursOn

func (b Biweekly) RecursOn(date Date) bool

func (Biweekly) String

func (b Biweekly) String() string

type Daily

type Daily struct {
	Start Date
}

func (Daily) RecursOn

func (d Daily) RecursOn(date Date) bool

func (Daily) String

func (d Daily) String() string

type Date

type Date struct {
	// contains filtered or unexported fields
}
var Today Date

func NewDate

func NewDate(year, month, day int) Date

func NewDateFromString

func NewDateFromString(date string) Date

func (Date) Add

func (d Date) Add(days int) Date

func (Date) AddDays

func (d Date) AddDays(amount int) Date

func (Date) AddMonths

func (d Date) AddMonths(addMonths int) Date

func (Date) After

func (d Date) After(ud Date) bool

After reports whether d is after ud

func (Date) Day

func (d Date) Day() int

func (Date) DaysBetween

func (d Date) DaysBetween(d2 Date) int

func (Date) Equal

func (d Date) Equal(ud Date) bool

func (Date) IsZero

func (d Date) IsZero() bool

func (Date) String

func (d Date) String() string

func (Date) Time

func (d Date) Time() time.Time

func (Date) Weekday

func (d Date) Weekday() time.Weekday

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(msender msend.MSender) *Dispatcher

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(t *Task) error

type EveryNMonths

type EveryNMonths struct {
	Start Date
	N     int
}

func (EveryNMonths) RecursOn

func (enm EveryNMonths) RecursOn(date Date) bool

func (EveryNMonths) String

func (enm EveryNMonths) String() string

type EveryNWeeks

type EveryNWeeks struct {
	Start Date
	N     int
}

func (EveryNWeeks) RecursOn

func (enw EveryNWeeks) RecursOn(date Date) bool

func (EveryNWeeks) String

func (enw EveryNWeeks) String() string

type Recurrer

type Recurrer interface {
	RecursOn(date Date) bool
	String() string
}

func NewRecurrer

func NewRecurrer(recurStr string) Recurrer

func ParseBiweekly

func ParseBiweekly(start Date, terms []string) (Recurrer, bool)

yyyy-mm-dd, biweekly, wednesday

func ParseDaily

func ParseDaily(start Date, terms []string) (Recurrer, bool)

func ParseEveryNMonths

func ParseEveryNMonths(start Date, terms []string) (Recurrer, bool)

yyyy-mm-dd, every 3 months

func ParseEveryNWeeks

func ParseEveryNWeeks(start Date, terms []string) (Recurrer, bool)

yyyy-mm-dd, every 3 weeks

func ParseWeekly

func ParseWeekly(start Date, terms []string) (Recurrer, bool)

yyyy-mm-dd, weekly, wednesday & saturday & sunday

type RemoteRepository

type RemoteRepository struct {
	// contains filtered or unexported fields
}

func NewRemoteRepository

func NewRemoteRepository(ms mstore.MStorer) *RemoteRepository

func (*RemoteRepository) Add

func (rr *RemoteRepository) Add(t *Task) error

func (*RemoteRepository) CleanUp

func (rr *RemoteRepository) CleanUp() error

Cleanup removes older versions of tasks

func (*RemoteRepository) FindAll

func (rr *RemoteRepository) FindAll(folder string) ([]*Task, error)

func (*RemoteRepository) Update

func (rr *RemoteRepository) Update(t *Task) error

type Task

type Task struct {
	Message *mstore.Message

	Id      string
	Version int
	Folder  string

	Action  string
	Project string
	Due     Date
	Recur   Recurrer
}

func NewFromMessage

func NewFromMessage(msg *mstore.Message) *Task

func (*Task) FormatBody

func (t *Task) FormatBody() string

func (*Task) FormatSubject

func (t *Task) FormatSubject() string

func (*Task) GenerateFromRecurrer

func (t *Task) GenerateFromRecurrer(date Date) (*Task, error)

func (*Task) IsRecurrer

func (t *Task) IsRecurrer() bool

func (*Task) NextMessage

func (t *Task) NextMessage() *mstore.Message

func (*Task) RecursOn

func (t *Task) RecursOn(date Date) bool

func (*Task) RecursToday

func (t *Task) RecursToday() bool

func (*Task) TargetFolder

func (t *Task) TargetFolder() string

type Weekdays

type Weekdays []time.Weekday

func (Weekdays) Len

func (wds Weekdays) Len() int

func (Weekdays) Less

func (wds Weekdays) Less(i, j int) bool

func (Weekdays) Swap

func (wds Weekdays) Swap(i, j int)

func (Weekdays) Unique

func (wds Weekdays) Unique() Weekdays

type Weekly

type Weekly struct {
	Start    Date
	Weekdays Weekdays
}

func (Weekly) RecursOn

func (w Weekly) RecursOn(date Date) bool

func (Weekly) String

func (w Weekly) String() string

Jump to

Keyboard shortcuts

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