task

package
v0.0.0-...-0202b1c Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATUS_FETCHED    = "fetched"
	STATUS_UPDATED    = "updated"
	STATUS_DISPATCHED = "dispatched"
)
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"
	FIELD_DONE    = "done"
)
View Source
const (
	DateFormat = "2006-01-02 (Monday)"
)

Variables

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

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 ByDefault

type ByDefault []*LocalTask

func (ByDefault) Len

func (lt ByDefault) Len() int

func (ByDefault) Less

func (lt ByDefault) Less(i, j int) bool

func (ByDefault) Swap

func (lt ByDefault) Swap(i, j int)

type ByDue

type ByDue []*LocalTask

func (ByDue) Len

func (lt ByDue) Len() int

func (ByDue) Less

func (lt ByDue) Less(i, j int) bool

func (ByDue) Swap

func (lt ByDue) Swap(i, j int)

type ById

type ById []*LocalTask

func (ById) Len

func (lt ById) Len() int

func (ById) Less

func (lt ById) Less(i, j int) bool

func (ById) Swap

func (lt ById) Swap(i, j int)

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
}

func NewDate

func NewDate(year, month, day int) Date

func NewDateFromString

func NewDateFromString(date string) Date

func Today

func Today() 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) Human

func (d Date) Human() string

func (Date) IsZero

func (d Date) IsZero() bool

func (*Date) MarshalJSON

func (d *Date) MarshalJSON() ([]byte, error)

func (Date) String

func (d Date) String() string

func (Date) Time

func (d Date) Time() time.Time

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

func (Date) Weekday

func (d Date) Weekday() time.Weekday

type EveryNDays

type EveryNDays struct {
	Start Date
	N     int
}

func (EveryNDays) RecursOn

func (nd EveryNDays) RecursOn(date Date) bool

func (EveryNDays) String

func (nd EveryNDays) String() string

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 LocalTask

type LocalTask struct {
	Task
	LocalId     int
	LocalUpdate *LocalUpdate
	LocalStatus string
}

func (*LocalTask) AddUpdate

func (lt *LocalTask) AddUpdate(update *LocalUpdate)

func (*LocalTask) ApplyUpdate

func (lt *LocalTask) ApplyUpdate()

func (*LocalTask) HasUpdate

func (lt *LocalTask) HasUpdate() bool

type LocalUpdate

type LocalUpdate struct {
	ForVersion int
	Fields     []string
	Action     string
	Project    string
	Due        Date
	Recur      Recurrer
	Done       bool
}

func (*LocalUpdate) Add

func (lu *LocalUpdate) Add(newUpdate *LocalUpdate)

func (*LocalUpdate) Scan

func (lu *LocalUpdate) Scan(value interface{}) error

func (LocalUpdate) Value

func (lu LocalUpdate) Value() (driver.Value, error)

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)

yyyy-mm-dd, daily

func ParseEveryNDays

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

yyyy-mm-dd, every 3 days

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 Task

type Task struct {
	// Message is the underlying message from which the task was created
	// It only has meaning for remote repositories and will be nil in
	// local situations. It will be filtered out in LocalRepository.SetTasks()
	Message *mstore.Message

	Id      string `json:"id"`
	Version int    `json:"version"`
	Folder  string `json:"folder"`

	Action  string   `json:"action"`
	Project string   `json:"project"`
	Due     Date     `json:"date"`
	Recur   Recurrer `json:"-"`
	Done    bool     `json:"done"`
}

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