async triggers for either interval or next due, accept cron
This commit is contained in:
@@ -24,6 +24,7 @@ type Task struct {
|
||||
Note []string
|
||||
Due time.Time
|
||||
Loop time.Duration
|
||||
Cron form.Cron
|
||||
|
||||
Index int
|
||||
}
|
||||
@@ -45,6 +46,7 @@ func New(r *http.Request) (*Task, error) {
|
||||
Edited: time.Now(),
|
||||
Due: form.ToTime(form.Get(r, "duedate")),
|
||||
Loop: form.ToDuration(form.Get(r, "loop")),
|
||||
Cron: form.Cron(form.Get(r, "cron")),
|
||||
}
|
||||
task.SetNote(form.Get(r, "note"))
|
||||
return task, task.validate()
|
||||
@@ -75,7 +77,8 @@ func (t *Task) MarshalJSON() ([]byte, error) {
|
||||
// "dueStr":"",
|
||||
// "dueInt":33330000,
|
||||
// "dueTitle":"Due ",
|
||||
// "loop": "1m"}
|
||||
// "loop": "1m",
|
||||
// "cron": "* * * * *"}
|
||||
// ]}
|
||||
fullFormat := "02 Jan 2006 03:04 PM"
|
||||
shortFormat := "02 Jan"
|
||||
@@ -112,6 +115,7 @@ func (t *Task) MarshalJSON() ([]byte, error) {
|
||||
"dueInt": t.Due.Unix(),
|
||||
"dueTitle": "Due ",
|
||||
"loop": t.Loop.String(),
|
||||
"cron": t.Cron,
|
||||
}
|
||||
if t.Due.IsZero() {
|
||||
for k := range m {
|
||||
|
||||
Reference in New Issue
Block a user