Return iso dates for everything date related from the api #130
|
@ -17,6 +17,7 @@
|
|||
package caldav
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/timeutil"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"code.vikunja.io/api/pkg/utils"
|
||||
"fmt"
|
||||
|
@ -34,37 +35,37 @@ type Event struct {
|
|||
UID string
|
||||
Alarms []Alarm
|
||||
|
||||
TimestampUnix int64
|
||||
StartUnix int64
|
||||
EndUnix int64
|
||||
Timestamp timeutil.TimeStamp
|
||||
Start timeutil.TimeStamp
|
||||
End timeutil.TimeStamp
|
||||
}
|
||||
|
||||
// Todo holds a single VTODO
|
||||
type Todo struct {
|
||||
// Required
|
||||
TimestampUnix int64
|
||||
UID string
|
||||
Timestamp timeutil.TimeStamp
|
||||
UID string
|
||||
|
||||
// Optional
|
||||
Summary string
|
||||
Description string
|
||||
CompletedUnix int64
|
||||
Organizer *user.User
|
||||
Priority int64 // 0-9, 1 is highest
|
||||
RelatedToUID string
|
||||
Summary string
|
||||
Description string
|
||||
Completed timeutil.TimeStamp
|
||||
Organizer *user.User
|
||||
Priority int64 // 0-9, 1 is highest
|
||||
RelatedToUID string
|
||||
|
||||
StartUnix int64
|
||||
EndUnix int64
|
||||
DueDateUnix int64
|
||||
Duration time.Duration
|
||||
Start timeutil.TimeStamp
|
||||
End timeutil.TimeStamp
|
||||
DueDate timeutil.TimeStamp
|
||||
Duration time.Duration
|
||||
|
||||
CreatedUnix int64
|
||||
UpdatedUnix int64 // last-mod
|
||||
Created timeutil.TimeStamp
|
||||
Updated timeutil.TimeStamp // last-mod
|
||||
}
|
||||
|
||||
// Alarm holds infos about an alarm from a caldav event
|
||||
type Alarm struct {
|
||||
TimeUnix int64
|
||||
Time timeutil.TimeStamp
|
||||
Description string
|
||||
}
|
||||
|
||||
|
@ -86,7 +87,7 @@ PRODID:-//` + config.ProdID + `//EN`
|
|||
for _, e := range events {
|
||||
|
||||
if e.UID == "" {
|
||||
e.UID = makeCalDavTimeFromUnixTime(e.TimestampUnix) + utils.Sha256(e.Summary)
|
||||
e.UID = makeCalDavTimeFromTimeStamp(e.Timestamp) + utils.Sha256(e.Summary)
|
||||
}
|
||||
|
||||
caldavevents += `
|
||||
|
@ -94,9 +95,9 @@ BEGIN:VEVENT
|
|||
UID:` + e.UID + `
|
||||
SUMMARY:` + e.Summary + `
|
||||
DESCRIPTION:` + e.Description + `
|
||||
DTSTAMP:` + makeCalDavTimeFromUnixTime(e.TimestampUnix) + `
|
||||
DTSTART:` + makeCalDavTimeFromUnixTime(e.StartUnix) + `
|
||||
DTEND:` + makeCalDavTimeFromUnixTime(e.EndUnix)
|
||||
DTSTAMP:` + makeCalDavTimeFromTimeStamp(e.Timestamp) + `
|
||||
DTSTART:` + makeCalDavTimeFromTimeStamp(e.Start) + `
|
||||
DTEND:` + makeCalDavTimeFromTimeStamp(e.End)
|
||||
|
||||
for _, a := range e.Alarms {
|
||||
if a.Description == "" {
|
||||
|
@ -105,7 +106,7 @@ DTEND:` + makeCalDavTimeFromUnixTime(e.EndUnix)
|
|||
|
||||
caldavevents += `
|
||||
BEGIN:VALARM
|
||||
TRIGGER:` + calcAlarmDateFromReminder(e.StartUnix, a.TimeUnix) + `
|
||||
TRIGGER:` + calcAlarmDateFromReminder(e.Start, a.Time) + `
|
||||
ACTION:DISPLAY
|
||||
DESCRIPTION:` + a.Description + `
|
||||
END:VALARM`
|
||||
|
@ -131,30 +132,30 @@ PRODID:-//` + config.ProdID + `//EN`
|
|||
|
||||
for _, t := range todos {
|
||||
if t.UID == "" {
|
||||
t.UID = makeCalDavTimeFromUnixTime(t.TimestampUnix) + utils.Sha256(t.Summary)
|
||||
t.UID = makeCalDavTimeFromTimeStamp(t.Timestamp) + utils.Sha256(t.Summary)
|
||||
}
|
||||
|
||||
caldavtodos += `
|
||||
BEGIN:VTODO
|
||||
UID:` + t.UID + `
|
||||
DTSTAMP:` + makeCalDavTimeFromUnixTime(t.TimestampUnix) + `
|
||||
DTSTAMP:` + makeCalDavTimeFromTimeStamp(t.Timestamp) + `
|
||||
SUMMARY:` + t.Summary
|
||||
|
||||
if t.StartUnix != 0 {
|
||||
if t.Start != 0 {
|
||||
caldavtodos += `
|
||||
DTSTART: ` + makeCalDavTimeFromUnixTime(t.StartUnix)
|
||||
DTSTART: ` + makeCalDavTimeFromTimeStamp(t.Start)
|
||||
}
|
||||
if t.EndUnix != 0 {
|
||||
if t.End != 0 {
|
||||
caldavtodos += `
|
||||
DTEND: ` + makeCalDavTimeFromUnixTime(t.EndUnix)
|
||||
DTEND: ` + makeCalDavTimeFromTimeStamp(t.End)
|
||||
}
|
||||
if t.Description != "" {
|
||||
caldavtodos += `
|
||||
DESCRIPTION:` + t.Description
|
||||
}
|
||||
if t.CompletedUnix != 0 {
|
||||
if t.Completed != 0 {
|
||||
caldavtodos += `
|
||||
COMPLETED: ` + makeCalDavTimeFromUnixTime(t.CompletedUnix)
|
||||
COMPLETED: ` + makeCalDavTimeFromTimeStamp(t.Completed)
|
||||
}
|
||||
if t.Organizer != nil {
|
||||
caldavtodos += `
|
||||
|
@ -166,14 +167,14 @@ ORGANIZER;CN=:` + t.Organizer.Username
|
|||
RELATED-TO:` + t.RelatedToUID
|
||||
}
|
||||
|
||||
if t.DueDateUnix != 0 {
|
||||
if t.DueDate != 0 {
|
||||
caldavtodos += `
|
||||
DUE:` + makeCalDavTimeFromUnixTime(t.DueDateUnix)
|
||||
DUE:` + makeCalDavTimeFromTimeStamp(t.DueDate)
|
||||
}
|
||||
|
||||
if t.CreatedUnix != 0 {
|
||||
if t.Created != 0 {
|
||||
caldavtodos += `
|
||||
CREATED:` + makeCalDavTimeFromUnixTime(t.CreatedUnix)
|
||||
CREATED:` + makeCalDavTimeFromTimeStamp(t.Created)
|
||||
}
|
||||
|
||||
if t.Duration != 0 {
|
||||
|
@ -187,7 +188,7 @@ PRIORITY:` + strconv.Itoa(int(t.Priority))
|
|||
}
|
||||
|
||||
caldavtodos += `
|
||||
LAST-MODIFIED:` + makeCalDavTimeFromUnixTime(t.UpdatedUnix)
|
||||
LAST-MODIFIED:` + makeCalDavTimeFromTimeStamp(t.Updated)
|
||||
|
||||
caldavtodos += `
|
||||
END:VTODO`
|
||||
|
@ -199,10 +200,9 @@ END:VCALENDAR` // Need a line break
|
|||
return
|
||||
}
|
||||
|
||||
func makeCalDavTimeFromUnixTime(unixtime int64) (caldavtime string) {
|
||||
func makeCalDavTimeFromTimeStamp(ts timeutil.TimeStamp) (caldavtime string) {
|
||||
tz, _ := time.LoadLocation("UTC")
|
||||
tm := time.Unix(unixtime, 0).In(tz)
|
||||
return tm.Format(DateFormat)
|
||||
return ts.ToTime().In(tz).Format(DateFormat)
|
||||
}
|
||||
|
||||
func calcAlarmDateFromReminder(eventStartUnix, reminderUnix int64) (alarmTime string) {
|
||||
|
|
|
@ -37,26 +37,26 @@ func TestParseEvents(t *testing.T) {
|
|||
},
|
||||
events: []*Event{
|
||||
{
|
||||
Summary: "Event #1",
|
||||
Description: "Lorem Ipsum",
|
||||
UID: "randommduid",
|
||||
TimestampUnix: 1543626724,
|
||||
StartUnix: 1543626724,
|
||||
EndUnix: 1543627824,
|
||||
Summary: "Event #1",
|
||||
Description: "Lorem Ipsum",
|
||||
UID: "randommduid",
|
||||
Timestamp: 1543626724,
|
||||
Start: 1543626724,
|
||||
End: 1543627824,
|
||||
},
|
||||
{
|
||||
Summary: "Event #2",
|
||||
UID: "randommduidd",
|
||||
TimestampUnix: 1543726724,
|
||||
StartUnix: 1543726724,
|
||||
EndUnix: 1543738724,
|
||||
Summary: "Event #2",
|
||||
UID: "randommduidd",
|
||||
Timestamp: 1543726724,
|
||||
Start: 1543726724,
|
||||
End: 1543738724,
|
||||
},
|
||||
{
|
||||
Summary: "Event #3 with empty uid",
|
||||
UID: "20181202T0600242aaef4a81d770c1e775e26bc5abebc87f1d3d7bffaa83",
|
||||
TimestampUnix: 1543726824,
|
||||
StartUnix: 1543726824,
|
||||
EndUnix: 1543727000,
|
||||
Summary: "Event #3 with empty uid",
|
||||
UID: "20181202T0600242aaef4a81d770c1e775e26bc5abebc87f1d3d7bffaa83",
|
||||
Timestamp: 1543726824,
|
||||
Start: 1543726824,
|
||||
End: 1543727000,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -101,47 +101,47 @@ END:VCALENDAR`,
|
|||
},
|
||||
events: []*Event{
|
||||
{
|
||||
Summary: "Event #1",
|
||||
Description: "Lorem Ipsum",
|
||||
UID: "randommduid",
|
||||
TimestampUnix: 1543626724,
|
||||
StartUnix: 1543626724,
|
||||
EndUnix: 1543627824,
|
||||
Summary: "Event #1",
|
||||
Description: "Lorem Ipsum",
|
||||
UID: "randommduid",
|
||||
Timestamp: 1543626724,
|
||||
Start: 1543626724,
|
||||
End: 1543627824,
|
||||
Alarms: []Alarm{
|
||||
{TimeUnix: 1543626524},
|
||||
{TimeUnix: 1543626224},
|
||||
{TimeUnix: 1543626024},
|
||||
{Time: 1543626524},
|
||||
{Time: 1543626224},
|
||||
{Time: 1543626024},
|
||||
},
|
||||
},
|
||||
{
|
||||
Summary: "Event #2",
|
||||
UID: "randommduidd",
|
||||
TimestampUnix: 1543726724,
|
||||
StartUnix: 1543726724,
|
||||
EndUnix: 1543738724,
|
||||
Summary: "Event #2",
|
||||
UID: "randommduidd",
|
||||
Timestamp: 1543726724,
|
||||
Start: 1543726724,
|
||||
End: 1543738724,
|
||||
Alarms: []Alarm{
|
||||
{TimeUnix: 1543626524},
|
||||
{TimeUnix: 1543626224},
|
||||
{TimeUnix: 1543626024},
|
||||
{Time: 1543626524},
|
||||
{Time: 1543626224},
|
||||
{Time: 1543626024},
|
||||
},
|
||||
},
|
||||
{
|
||||
Summary: "Event #3 with empty uid",
|
||||
TimestampUnix: 1543726824,
|
||||
StartUnix: 1543726824,
|
||||
EndUnix: 1543727000,
|
||||
Summary: "Event #3 with empty uid",
|
||||
Timestamp: 1543726824,
|
||||
Start: 1543726824,
|
||||
End: 1543727000,
|
||||
Alarms: []Alarm{
|
||||
{TimeUnix: 1543626524},
|
||||
{TimeUnix: 1543626224},
|
||||
{TimeUnix: 1543626024},
|
||||
{TimeUnix: 1543826824},
|
||||
{Time: 1543626524},
|
||||
{Time: 1543626224},
|
||||
{Time: 1543626024},
|
||||
{Time: 1543826824},
|
||||
},
|
||||
},
|
||||
{
|
||||
Summary: "Event #4 without any",
|
||||
TimestampUnix: 1543726824,
|
||||
StartUnix: 1543726824,
|
||||
EndUnix: 1543727000,
|
||||
Summary: "Event #4 without any",
|
||||
Timestamp: 1543726824,
|
||||
Start: 1543726824,
|
||||
End: 1543727000,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -18,6 +18,7 @@ package files
|
|||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/timeutil"
|
||||
"code.vikunja.io/web"
|
||||
"github.com/c2h5oh/datasize"
|
||||
"github.com/spf13/afero"
|
||||
|
@ -35,8 +36,8 @@ type File struct {
|
|||
|
||||
Created time.Time `xorm:"-" json:"created"`
|
||||
|
||||
CreatedUnix int64 `xorm:"created" json:"-"`
|
||||
CreatedByID int64 `xorm:"int(11) not null" json:"-"`
|
||||
CreatedUnix timeutil.TimeStamp `xorm:"created" json:"-"`
|
||||
CreatedByID int64 `xorm:"int(11) not null" json:"-"`
|
||||
|
||||
File afero.File `xorm:"-" json:"-"`
|
||||
// This ReadCloser is only used for migration purposes. Use with care!
|
||||
|
@ -65,7 +66,7 @@ func (f *File) LoadFileMetaByID() (err error) {
|
|||
if !exists {
|
||||
return ErrFileDoesNotExist{FileID: f.ID}
|
||||
}
|
||||
f.Created = time.Unix(f.CreatedUnix, 0)
|
||||
f.Created = f.CreatedUnix.ToTime()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ type LabelTask struct {
|
|||
TaskID int64 `xorm:"int(11) INDEX not null" json:"-" param:"listtask"`
|
||||
// The label id you want to associate with a task.
|
||||
LabelID int64 `xorm:"int(11) INDEX not null" json:"label_id" param:"label"`
|
||||
// A unix timestamp when this task was created. You cannot change this value.
|
||||
// A timestamp when this task was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
|
|
|
@ -53,9 +53,9 @@ type LinkSharing struct {
|
|||
SharedBy *user.User `xorm:"-" json:"shared_by"`
|
||||
SharedByID int64 `xorm:"int(11) INDEX not null" json:"-"`
|
||||
|
||||
// A unix timestamp when this list was shared. You cannot change this value.
|
||||
// A timestamp when this list was shared. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
// A unix timestamp when this share was last updated. You cannot change this value.
|
||||
// A timestamp when this share was last updated. You cannot change this value.
|
||||
Updated timeutil.TimeStamp `xorm:"updated not null" json:"updated"`
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
|
|
|
@ -43,9 +43,9 @@ type List struct {
|
|||
// Deprecated: you should use the dedicated task list endpoint because it has support for pagination and filtering
|
||||
Tasks []*Task `xorm:"-" json:"-"`
|
||||
|
||||
// A unix timestamp when this list was created. You cannot change this value.
|
||||
// A timestamp when this list was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
// A unix timestamp when this list was last updated. You cannot change this value.
|
||||
// A timestamp when this list was last updated. You cannot change this value.
|
||||
Updated timeutil.TimeStamp `xorm:"updated not null" json:"updated"`
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
|
|
|
@ -32,9 +32,9 @@ type TeamList struct {
|
|||
// The right this team has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
|
||||
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
|
||||
|
||||
// A unix timestamp when this relation was created. You cannot change this value.
|
||||
// A timestamp when this relation was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
// A unix timestamp when this relation was last updated. You cannot change this value.
|
||||
// A timestamp when this relation was last updated. You cannot change this value.
|
||||
Updated timeutil.TimeStamp `xorm:"updated not null" json:"updated"`
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
|
|
|
@ -35,9 +35,9 @@ type ListUser struct {
|
|||
// The right this user has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
|
||||
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
|
||||
|
||||
// A unix timestamp when this relation was created. You cannot change this value.
|
||||
// A timestamp when this relation was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
// A unix timestamp when this relation was last updated. You cannot change this value.
|
||||
// A timestamp when this relation was last updated. You cannot change this value.
|
||||
Updated timeutil.TimeStamp `xorm:"updated not null" json:"updated"`
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
|
|
|
@ -38,9 +38,9 @@ type Namespace struct {
|
|||
// The user who owns this namespace
|
||||
Owner *user.User `xorm:"-" json:"owner" valid:"-"`
|
||||
|
||||
// A unix timestamp when this namespace was created. You cannot change this value.
|
||||
// A timestamp when this namespace was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
// A unix timestamp when this namespace was last updated. You cannot change this value.
|
||||
// A timestamp when this namespace was last updated. You cannot change this value.
|
||||
Updated timeutil.TimeStamp `xorm:"updated not null" json:"updated"`
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
|
|
|
@ -34,9 +34,9 @@ type NamespaceUser struct {
|
|||
// The right this user has. 0 = Read only, 1 = Read & Write, 2 = Admin. See the docs for more details.
|
||||
Right Right `xorm:"int(11) INDEX not null default 0" json:"right" valid:"length(0|2)" maximum:"2" default:"0"`
|
||||
|
||||
// A unix timestamp when this relation was created. You cannot change this value.
|
||||
// A timestamp when this relation was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
// A unix timestamp when this relation was last updated. You cannot change this value.
|
||||
// A timestamp when this relation was last updated. You cannot change this value.
|
||||
Updated timeutil.TimeStamp `xorm:"updated not null" json:"updated"`
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
"code.vikunja.io/api/pkg/user"
|
||||
"code.vikunja.io/web"
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TaskAttachment is the definition of a task attachment
|
||||
|
@ -146,7 +145,7 @@ func (ta *TaskAttachment) ReadAll(a web.Auth, search string, page int, perPage i
|
|||
continue
|
||||
}
|
||||
r.File = fs[r.FileID]
|
||||
r.File.Created = time.Unix(r.File.CreatedUnix, 0)
|
||||
r.File.Created = r.File.CreatedUnix.ToTime()
|
||||
r.CreatedBy = us[r.CreatedByID]
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ type TaskCollection struct {
|
|||
// @Param s query string false "Search tasks by task text."
|
||||
// @Param sort_by query string false "The sorting parameter. You can pass this multiple times to get the tasks ordered by multiple different parametes, along with `order_by`. Possible values to sort by are `id`, `text`, `description`, `done`, `done_at_unix`, `due_date_unix`, `created_by_id`, `list_id`, `repeat_after`, `priority`, `start_date_unix`, `end_date_unix`, `hex_color`, `percent_done`, `uid`, `created`, `updated`. Default is `id`."
|
||||
// @Param order_by query string false "The ordering parameter. Possible values to order by are `asc` or `desc`. Default is `asc`."
|
||||
// @Param startdate query int false "The start date parameter to filter by. Expects a unix timestamp. If no end date, but a start date is specified, the end date is set to the current time."
|
||||
// @Param enddate query int false "The end date parameter to filter by. Expects a unix timestamp. If no start date, but an end date is specified, the start date is set to the current time."
|
||||
// @Param startdate query int false "The start date parameter to filter by. Expects a timestamp. If no end date, but a start date is specified, the end date is set to the current time."
|
||||
// @Param enddate query int false "The end date parameter to filter by. Expects a timestamp. If no start date, but an end date is specified, the start date is set to the current time."
|
||||
// @Security JWTKeyAuth
|
||||
// @Success 200 {array} models.Task "The tasks"
|
||||
// @Failure 500 {object} models.Message "Internal error"
|
||||
|
|
|
@ -165,14 +165,14 @@ var propertyComparators = map[sortProperty]taskComparator{
|
|||
taskPropertyText: mustMakeComparator("Text"),
|
||||
taskPropertyDescription: mustMakeComparator("Description"),
|
||||
taskPropertyDone: mustMakeComparator("Done"),
|
||||
taskPropertyDoneAtUnix: mustMakeComparator("DoneAtUnix"),
|
||||
taskPropertyDueDateUnix: mustMakeComparator("DueDateUnix"),
|
||||
taskPropertyDoneAtUnix: mustMakeComparator("DoneAt"),
|
||||
taskPropertyDueDateUnix: mustMakeComparator("DueDate"),
|
||||
taskPropertyCreatedByID: mustMakeComparator("CreatedByID"),
|
||||
taskPropertyListID: mustMakeComparator("ListID"),
|
||||
taskPropertyRepeatAfter: mustMakeComparator("RepeatAfter"),
|
||||
taskPropertyPriority: mustMakeComparator("Priority"),
|
||||
taskPropertyStartDateUnix: mustMakeComparator("StartDateUnix"),
|
||||
taskPropertyEndDateUnix: mustMakeComparator("EndDateUnix"),
|
||||
taskPropertyStartDateUnix: mustMakeComparator("StartDate"),
|
||||
taskPropertyEndDateUnix: mustMakeComparator("EndDate"),
|
||||
taskPropertyHexColor: mustMakeComparator("HexColor"),
|
||||
taskPropertyPercentDone: mustMakeComparator("PercentDone"),
|
||||
taskPropertyUID: mustMakeComparator("UID"),
|
||||
|
|
|
@ -99,29 +99,29 @@ var (
|
|||
Text: "aaa",
|
||||
Description: "Lorem Ipsum",
|
||||
Done: true,
|
||||
DoneAtUnix: 1543626000,
|
||||
DoneAt: 1543626000,
|
||||
ListID: 1,
|
||||
UID: "JywtBPCESImlyKugvaZWrxmXAFAWXFISMeXYImEh",
|
||||
Created: 1543626724,
|
||||
Updated: 1543626724,
|
||||
}
|
||||
task2 = &Task{
|
||||
ID: 2,
|
||||
Text: "bbb",
|
||||
Description: "Arem Ipsum",
|
||||
Done: true,
|
||||
DoneAtUnix: 1543626724,
|
||||
CreatedByID: 1,
|
||||
ListID: 2,
|
||||
PercentDone: 0.3,
|
||||
StartDateUnix: 1543626724,
|
||||
Created: 1553626724,
|
||||
Updated: 1553626724,
|
||||
ID: 2,
|
||||
Text: "bbb",
|
||||
Description: "Arem Ipsum",
|
||||
Done: true,
|
||||
DoneAt: 1543626724,
|
||||
CreatedByID: 1,
|
||||
ListID: 2,
|
||||
PercentDone: 0.3,
|
||||
StartDate: 1543626724,
|
||||
Created: 1553626724,
|
||||
Updated: 1553626724,
|
||||
}
|
||||
task3 = &Task{
|
||||
ID: 3,
|
||||
Text: "ccc",
|
||||
DueDateUnix: 1583626724,
|
||||
DueDate: 1583626724,
|
||||
Priority: 100,
|
||||
ListID: 3,
|
||||
HexColor: "000000",
|
||||
|
@ -129,49 +129,49 @@ var (
|
|||
Updated: 1555555555,
|
||||
}
|
||||
task4 = &Task{
|
||||
ID: 4,
|
||||
Text: "ddd",
|
||||
Priority: 1,
|
||||
StartDateUnix: 1643626724,
|
||||
ListID: 1,
|
||||
ID: 4,
|
||||
Text: "ddd",
|
||||
Priority: 1,
|
||||
StartDate: 1643626724,
|
||||
ListID: 1,
|
||||
}
|
||||
task5 = &Task{
|
||||
ID: 5,
|
||||
Text: "eef",
|
||||
Priority: 50,
|
||||
UID: "shggzCHQWLhGNMNsOGOCOjcVkInOYjTAnORqTkdL",
|
||||
DueDateUnix: 1543636724,
|
||||
Updated: 1565555555,
|
||||
ID: 5,
|
||||
Text: "eef",
|
||||
Priority: 50,
|
||||
UID: "shggzCHQWLhGNMNsOGOCOjcVkInOYjTAnORqTkdL",
|
||||
DueDate: 1543636724,
|
||||
Updated: 1565555555,
|
||||
}
|
||||
task6 = &Task{
|
||||
ID: 6,
|
||||
Text: "eef",
|
||||
DueDateUnix: 1543616724,
|
||||
DueDate: 1543616724,
|
||||
RepeatAfter: 6400,
|
||||
CreatedByID: 2,
|
||||
HexColor: "ffffff",
|
||||
}
|
||||
task7 = &Task{
|
||||
ID: 7,
|
||||
Text: "mmmn",
|
||||
Description: "Zoremis",
|
||||
StartDateUnix: 1544600000,
|
||||
EndDateUnix: 1584600000,
|
||||
UID: "tyzCZuLMSKhwclJOsDyDcUdyVAPBDOPHNTBOLTcW",
|
||||
ID: 7,
|
||||
Text: "mmmn",
|
||||
Description: "Zoremis",
|
||||
StartDate: 1544600000,
|
||||
EndDate: 1584600000,
|
||||
UID: "tyzCZuLMSKhwclJOsDyDcUdyVAPBDOPHNTBOLTcW",
|
||||
}
|
||||
task8 = &Task{
|
||||
ID: 8,
|
||||
Text: "b123",
|
||||
EndDateUnix: 1544700000,
|
||||
ID: 8,
|
||||
Text: "b123",
|
||||
EndDate: 1544700000,
|
||||
}
|
||||
task9 = &Task{
|
||||
ID: 9,
|
||||
Done: true,
|
||||
DoneAtUnix: 1573626724,
|
||||
Text: "a123",
|
||||
RepeatAfter: 86000,
|
||||
StartDateUnix: 1544600000,
|
||||
EndDateUnix: 1544700000,
|
||||
ID: 9,
|
||||
Done: true,
|
||||
DoneAt: 1573626724,
|
||||
Text: "a123",
|
||||
RepeatAfter: 86000,
|
||||
StartDate: 1544600000,
|
||||
EndDate: 1544700000,
|
||||
}
|
||||
task10 = &Task{
|
||||
ID: 10,
|
||||
|
|
|
@ -168,7 +168,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
RelatedTasks: map[RelationKind][]*Task{},
|
||||
Created: 1543626724,
|
||||
Updated: 1543626724,
|
||||
DueDateUnix: 1543636724,
|
||||
DueDate: 1543636724,
|
||||
}
|
||||
task6 := &Task{
|
||||
ID: 6,
|
||||
|
@ -181,20 +181,20 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
RelatedTasks: map[RelationKind][]*Task{},
|
||||
Created: 1543626724,
|
||||
Updated: 1543626724,
|
||||
DueDateUnix: 1543616724,
|
||||
DueDate: 1543616724,
|
||||
}
|
||||
task7 := &Task{
|
||||
ID: 7,
|
||||
Text: "task #7 with start date",
|
||||
Identifier: "test1-7",
|
||||
Index: 7,
|
||||
CreatedByID: 1,
|
||||
CreatedBy: user1,
|
||||
ListID: 1,
|
||||
RelatedTasks: map[RelationKind][]*Task{},
|
||||
Created: 1543626724,
|
||||
Updated: 1543626724,
|
||||
StartDateUnix: 1544600000,
|
||||
ID: 7,
|
||||
Text: "task #7 with start date",
|
||||
Identifier: "test1-7",
|
||||
Index: 7,
|
||||
CreatedByID: 1,
|
||||
CreatedBy: user1,
|
||||
ListID: 1,
|
||||
RelatedTasks: map[RelationKind][]*Task{},
|
||||
Created: 1543626724,
|
||||
Updated: 1543626724,
|
||||
StartDate: 1544600000,
|
||||
}
|
||||
task8 := &Task{
|
||||
ID: 8,
|
||||
|
@ -207,21 +207,21 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
RelatedTasks: map[RelationKind][]*Task{},
|
||||
Created: 1543626724,
|
||||
Updated: 1543626724,
|
||||
EndDateUnix: 1544700000,
|
||||
EndDate: 1544700000,
|
||||
}
|
||||
task9 := &Task{
|
||||
ID: 9,
|
||||
Text: "task #9 with start and end date",
|
||||
Identifier: "test1-9",
|
||||
Index: 9,
|
||||
CreatedByID: 1,
|
||||
CreatedBy: user1,
|
||||
ListID: 1,
|
||||
RelatedTasks: map[RelationKind][]*Task{},
|
||||
Created: 1543626724,
|
||||
Updated: 1543626724,
|
||||
StartDateUnix: 1544600000,
|
||||
EndDateUnix: 1544700000,
|
||||
ID: 9,
|
||||
Text: "task #9 with start and end date",
|
||||
Identifier: "test1-9",
|
||||
Index: 9,
|
||||
CreatedByID: 1,
|
||||
CreatedBy: user1,
|
||||
ListID: 1,
|
||||
RelatedTasks: map[RelationKind][]*Task{},
|
||||
Created: 1543626724,
|
||||
Updated: 1543626724,
|
||||
StartDate: 1544600000,
|
||||
EndDate: 1544700000,
|
||||
}
|
||||
task10 := &Task{
|
||||
ID: 10,
|
||||
|
|
|
@ -87,7 +87,7 @@ type TaskRelation struct {
|
|||
// The user who created this relation
|
||||
CreatedBy *user.User `xorm:"-" json:"created_by"`
|
||||
|
||||
// A unix timestamp when this label was created. You cannot change this value.
|
||||
// A timestamp when this label was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
|
|
|
@ -39,11 +39,11 @@ type Task struct {
|
|||
Description string `xorm:"longtext null" json:"description"`
|
||||
// Whether a task is done or not.
|
||||
Done bool `xorm:"INDEX null" json:"done"`
|
||||
// The unix timestamp when a task was marked as done.
|
||||
DoneAtUnix int64 `xorm:"INDEX null" json:"doneAt"`
|
||||
// A unix timestamp when the task is due.
|
||||
DueDateUnix int64 `xorm:"int(11) INDEX null" json:"dueDate"`
|
||||
// An array of unix timestamps when the user wants to be reminded of the task.
|
||||
// The time when a task was marked as done.
|
||||
DoneAt timeutil.TimeStamp `xorm:"INDEX null 'done_at_unix'" json:"doneAt"`
|
||||
// The time when the task is due.
|
||||
DueDate timeutil.TimeStamp `xorm:"int(11) INDEX null 'due_date_unix'" json:"dueDate"`
|
||||
// An array of datetimes when the user wants to be reminded of the task.
|
||||
Reminders []timeutil.TimeStamp `xorm:"-" json:"reminderDates"`
|
||||
CreatedByID int64 `xorm:"int(11) not null" json:"-"` // ID of the user who put that task on the list
|
||||
// The list this task belongs to.
|
||||
|
@ -53,9 +53,9 @@ type Task struct {
|
|||
// The task priority. Can be anything you want, it is possible to sort by this later.
|
||||
Priority int64 `xorm:"int(11) null" json:"priority"`
|
||||
// When this task starts.
|
||||
StartDateUnix int64 `xorm:"int(11) INDEX null" json:"startDate" query:"-"`
|
||||
StartDate timeutil.TimeStamp `xorm:"int(11) INDEX null 'start_date_unix'" json:"startDate" query:"-"`
|
||||
// When this task ends.
|
||||
EndDateUnix int64 `xorm:"int(11) INDEX null" json:"endDate" query:"-"`
|
||||
EndDate timeutil.TimeStamp `xorm:"int(11) INDEX null 'end_date_unix'" json:"endDate" query:"-"`
|
||||
// An array of users who are assigned to this task
|
||||
Assignees []*user.User `xorm:"-" json:"assignees"`
|
||||
// An array of labels which are associated with this task.
|
||||
|
@ -73,19 +73,15 @@ type Task struct {
|
|||
// The UID is currently not used for anything other than caldav, which is why we don't expose it over json
|
||||
UID string `xorm:"varchar(250) null" json:"-"`
|
||||
|
||||
Sorting string `xorm:"-" json:"-" query:"sort"` // Parameter to sort by
|
||||
StartDateSortUnix int64 `xorm:"-" json:"-" query:"startdate"`
|
||||
EndDateSortUnix int64 `xorm:"-" json:"-" query:"enddate"`
|
||||
|
||||
// All related tasks, grouped by their relation kind
|
||||
RelatedTasks RelatedTaskMap `xorm:"-" json:"related_tasks"`
|
||||
|
||||
// All attachments this task has
|
||||
Attachments []*TaskAttachment `xorm:"-" json:"attachments"`
|
||||
|
||||
// A unix timestamp when this task was created. You cannot change this value.
|
||||
// A timestamp when this task was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
// A unix timestamp when this task was last updated. You cannot change this value.
|
||||
// A timestamp when this task was last updated. You cannot change this value.
|
||||
Updated timeutil.TimeStamp `xorm:"updated not null" json:"updated"`
|
||||
|
||||
// The user who initially created the task.
|
||||
|
@ -132,8 +128,8 @@ type taskOptions struct {
|
|||
// @Param per_page query int false "The maximum number of items per page. Note this parameter is limited by the configured maximum of items per page."
|
||||
// @Param s query string false "Search tasks by task text."
|
||||
// @Param sort query string false "The sorting parameter. Possible values to sort by are priority, prioritydesc, priorityasc, duedate, duedatedesc, duedateasc."
|
||||
// @Param startdate query int false "The start date parameter to filter by. Expects a unix timestamp. If no end date, but a start date is specified, the end date is set to the current time."
|
||||
// @Param enddate query int false "The end date parameter to filter by. Expects a unix timestamp. If no start date, but an end date is specified, the start date is set to the current time."
|
||||
// @Param startdate query int false "The start date parameter to filter by. Expects a timestamp. If no end date, but a start date is specified, the end date is set to the current time."
|
||||
// @Param enddate query int false "The end date parameter to filter by. Expects a timestamp. If no start date, but an end date is specified, the start date is set to the current time."
|
||||
// @Security JWTKeyAuth
|
||||
// @Success 200 {array} models.Task "The tasks"
|
||||
// @Failure 500 {object} models.Message "Internal error"
|
||||
|
@ -604,20 +600,20 @@ func (t *Task) Update() (err error) {
|
|||
ot.Description = ""
|
||||
}
|
||||
// Due date
|
||||
if t.DueDateUnix == 0 {
|
||||
ot.DueDateUnix = 0
|
||||
if t.DueDate == 0 {
|
||||
ot.DueDate = 0
|
||||
}
|
||||
// Repeat after
|
||||
if t.RepeatAfter == 0 {
|
||||
ot.RepeatAfter = 0
|
||||
}
|
||||
// Start date
|
||||
if t.StartDateUnix == 0 {
|
||||
ot.StartDateUnix = 0
|
||||
if t.StartDate == 0 {
|
||||
ot.StartDate = 0
|
||||
}
|
||||
// End date
|
||||
if t.EndDateUnix == 0 {
|
||||
ot.EndDateUnix = 0
|
||||
if t.EndDate == 0 {
|
||||
ot.EndDate = 0
|
||||
}
|
||||
// Color
|
||||
if t.HexColor == "" {
|
||||
|
@ -654,7 +650,7 @@ func (t *Task) Update() (err error) {
|
|||
// with updated values into the db)
|
||||
func updateDone(oldTask *Task, newTask *Task) {
|
||||
if !oldTask.Done && newTask.Done && oldTask.RepeatAfter > 0 {
|
||||
oldTask.DueDateUnix = oldTask.DueDateUnix + oldTask.RepeatAfter // assuming we'll save the old task (merged)
|
||||
oldTask.DueDate = timeutil.FromTime(oldTask.DueDate.ToTime().Add(time.Duration(oldTask.RepeatAfter) * time.Second)) // assuming we'll save the old task (merged)
|
||||
|
||||
for in, r := range oldTask.Reminders {
|
||||
oldTask.Reminders[in] = timeutil.FromTime(r.ToTime().Add(time.Duration(oldTask.RepeatAfter) * time.Second))
|
||||
|
@ -665,11 +661,11 @@ func updateDone(oldTask *Task, newTask *Task) {
|
|||
|
||||
// Update the "done at" timestamp
|
||||
if !oldTask.Done && newTask.Done {
|
||||
oldTask.DoneAtUnix = time.Now().Unix()
|
||||
oldTask.DoneAt = timeutil.FromTime(time.Now())
|
||||
}
|
||||
// When unmarking a task as done, reset the timestamp
|
||||
if oldTask.Done && !newTask.Done {
|
||||
oldTask.DoneAtUnix = 0
|
||||
oldTask.DoneAt = 0
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,14 +127,14 @@ func TestUpdateDone(t *testing.T) {
|
|||
oldTask := &Task{Done: false}
|
||||
newTask := &Task{Done: true}
|
||||
updateDone(oldTask, newTask)
|
||||
assert.NotEqual(t, int64(0), oldTask.DoneAtUnix)
|
||||
assert.NotEqual(t, int64(0), oldTask.DoneAt)
|
||||
})
|
||||
t.Run("unmarking a task as done", func(t *testing.T) {
|
||||
db.LoadAndAssertFixtures(t)
|
||||
oldTask := &Task{Done: true}
|
||||
newTask := &Task{Done: false}
|
||||
updateDone(oldTask, newTask)
|
||||
assert.Equal(t, int64(0), oldTask.DoneAtUnix)
|
||||
assert.Equal(t, int64(0), oldTask.DoneAt)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ type Team struct {
|
|||
// An array of all members in this team.
|
||||
Members []*TeamUser `xorm:"-" json:"members"`
|
||||
|
||||
// A unix timestamp when this relation was created. You cannot change this value.
|
||||
// A timestamp when this relation was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created" json:"created"`
|
||||
// A unix timestamp when this relation was last updated. You cannot change this value.
|
||||
// A timestamp when this relation was last updated. You cannot change this value.
|
||||
Updated timeutil.TimeStamp `xorm:"updated" json:"updated"`
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
|
@ -70,7 +70,7 @@ type TeamMember struct {
|
|||
// Whether or not the member is an admin of the team. See the docs for more about what a team admin can do
|
||||
Admin bool `xorm:"tinyint(1) INDEX null" json:"admin"`
|
||||
|
||||
// A unix timestamp when this relation was created. You cannot change this value.
|
||||
// A timestamp when this relation was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
|
||||
web.CRUDable `xorm:"-" json:"-"`
|
||||
|
|
|
@ -17,15 +17,16 @@
|
|||
package migration
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/timeutil"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
)
|
||||
|
||||
// Status represents this migration status
|
||||
type Status struct {
|
||||
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
|
||||
UserID int64 `xorm:"int(11) not null" json:"-"`
|
||||
MigratorName string `xorm:"varchar(255)" json:"migrator_name"`
|
||||
CreatedUnix int64 `xorm:"created not null" json:"time_unix"`
|
||||
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
|
||||
UserID int64 `xorm:"int(11) not null" json:"-"`
|
||||
MigratorName string `xorm:"varchar(255)" json:"migrator_name"`
|
||||
Created timeutil.TimeStamp `xorm:"created not null 'created_unix'" json:"time_unix"`
|
||||
}
|
||||
|
||||
// TableName holds the table name for the migration status table
|
||||
|
|
|
@ -159,7 +159,7 @@ func convertListForFolder(listID int, list *list, content *wunderlistContents) (
|
|||
|
||||
// Set Done At
|
||||
if newTask.Done {
|
||||
newTask.DoneAtUnix = t.CompletedAt.Unix()
|
||||
newTask.DoneAt = timeutil.FromTime(t.CompletedAt)
|
||||
}
|
||||
|
||||
// Parse the due date
|
||||
|
@ -168,7 +168,7 @@ func convertListForFolder(listID int, list *list, content *wunderlistContents) (
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newTask.DueDateUnix = dueDate.Unix()
|
||||
newTask.DueDate = timeutil.FromTime(dueDate)
|
||||
}
|
||||
|
||||
// Find related notes
|
||||
|
@ -199,7 +199,7 @@ func convertListForFolder(listID int, list *list, content *wunderlistContents) (
|
|||
Mime: f.ContentType,
|
||||
Size: uint64(f.FileSize),
|
||||
Created: f.CreatedAt,
|
||||
CreatedUnix: f.CreatedAt.Unix(),
|
||||
CreatedUnix: timeutil.FromTime(f.CreatedAt),
|
||||
// We directly pass the file contents here to have a way to link the attachment to the file later.
|
||||
// Because we don't have an ID for our task at this point of the migration, we cannot just throw all
|
||||
// attachments in a slice and do the work of downloading and properly storing them later.
|
||||
|
|
|
@ -203,7 +203,7 @@ func TestWunderlistParsing(t *testing.T) {
|
|||
Tasks: []*models.Task{
|
||||
{
|
||||
Text: "Ipsum1",
|
||||
DueDateUnix: 1378339200,
|
||||
DueDate: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Description: "Lorem Ipsum dolor sit amet",
|
||||
Attachments: []*models.TaskAttachment{
|
||||
|
@ -213,7 +213,7 @@ func TestWunderlistParsing(t *testing.T) {
|
|||
Mime: "text/plain",
|
||||
Size: 12345,
|
||||
Created: time2,
|
||||
CreatedUnix: time2.Unix(),
|
||||
CreatedUnix: timeutil.FromTime(time2),
|
||||
FileContent: exampleFile,
|
||||
},
|
||||
Created: timeutil.FromTime(time2),
|
||||
|
@ -223,7 +223,7 @@ func TestWunderlistParsing(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Text: "Ipsum2",
|
||||
DueDateUnix: 1378339200,
|
||||
DueDate: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Description: "Lorem Ipsum dolor sit amet",
|
||||
RelatedTasks: map[models.RelationKind][]*models.Task{
|
||||
|
@ -246,8 +246,8 @@ func TestWunderlistParsing(t *testing.T) {
|
|||
{
|
||||
Text: "Ipsum3",
|
||||
Done: true,
|
||||
DoneAtUnix: time1.Unix(),
|
||||
DueDateUnix: 1378339200,
|
||||
DoneAt: timeutil.FromTime(time1),
|
||||
DueDate: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Description: "Lorem Ipsum dolor sit amet",
|
||||
Attachments: []*models.TaskAttachment{
|
||||
|
@ -257,7 +257,7 @@ func TestWunderlistParsing(t *testing.T) {
|
|||
Mime: "text/plain",
|
||||
Size: 12345,
|
||||
Created: time3,
|
||||
CreatedUnix: time3.Unix(),
|
||||
CreatedUnix: timeutil.FromTime(time3),
|
||||
FileContent: exampleFile,
|
||||
},
|
||||
Created: timeutil.FromTime(time3),
|
||||
|
@ -265,10 +265,10 @@ func TestWunderlistParsing(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
Text: "Ipsum4",
|
||||
DueDateUnix: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Reminders: []timeutil.TimeStamp{timeutil.FromTime(time3)},
|
||||
Text: "Ipsum4",
|
||||
DueDate: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Reminders: []timeutil.TimeStamp{timeutil.FromTime(time3)},
|
||||
RelatedTasks: map[models.RelationKind][]*models.Task{
|
||||
models.RelationKindSubtask: {
|
||||
{
|
||||
|
@ -284,28 +284,28 @@ func TestWunderlistParsing(t *testing.T) {
|
|||
Title: "Lorem3",
|
||||
Tasks: []*models.Task{
|
||||
{
|
||||
Text: "Ipsum5",
|
||||
DueDateUnix: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Text: "Ipsum5",
|
||||
DueDate: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
},
|
||||
{
|
||||
Text: "Ipsum6",
|
||||
DueDateUnix: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Done: true,
|
||||
DoneAtUnix: time1.Unix(),
|
||||
Text: "Ipsum6",
|
||||
DueDate: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Done: true,
|
||||
DoneAt: timeutil.FromTime(time1),
|
||||
},
|
||||
{
|
||||
Text: "Ipsum7",
|
||||
DueDateUnix: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Done: true,
|
||||
DoneAtUnix: time1.Unix(),
|
||||
Text: "Ipsum7",
|
||||
DueDate: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Done: true,
|
||||
DoneAt: timeutil.FromTime(time1),
|
||||
},
|
||||
{
|
||||
Text: "Ipsum8",
|
||||
DueDateUnix: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Text: "Ipsum8",
|
||||
DueDate: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -314,18 +314,18 @@ func TestWunderlistParsing(t *testing.T) {
|
|||
Title: "Lorem4",
|
||||
Tasks: []*models.Task{
|
||||
{
|
||||
Text: "Ipsum9",
|
||||
DueDateUnix: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Done: true,
|
||||
DoneAtUnix: time1.Unix(),
|
||||
Text: "Ipsum9",
|
||||
DueDate: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Done: true,
|
||||
DoneAt: timeutil.FromTime(time1),
|
||||
},
|
||||
{
|
||||
Text: "Ipsum10",
|
||||
DueDateUnix: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Done: true,
|
||||
DoneAtUnix: time1.Unix(),
|
||||
Text: "Ipsum10",
|
||||
DueDate: 1378339200,
|
||||
Created: timeutil.FromTime(time1),
|
||||
Done: true,
|
||||
DoneAt: timeutil.FromTime(time1),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -32,23 +32,23 @@ func getCaldavTodosForTasks(list *models.List) string {
|
|||
var caldavtodos []*caldav.Todo
|
||||
for _, t := range list.Tasks {
|
||||
|
||||
durationString := t.EndDateUnix - t.StartDateUnix
|
||||
durationString := t.EndDate - t.StartDate
|
||||
duration, _ := time.ParseDuration(strconv.FormatInt(durationString, 10) + `s`)
|
||||
|
||||
caldavtodos = append(caldavtodos, &caldav.Todo{
|
||||
TimestampUnix: t.Updated.ToTime().Unix(),
|
||||
UID: t.UID,
|
||||
Summary: t.Text,
|
||||
Description: t.Description,
|
||||
CompletedUnix: t.DoneAtUnix,
|
||||
Timestamp: t.Updated,
|
||||
UID: t.UID,
|
||||
Summary: t.Text,
|
||||
Description: t.Description,
|
||||
Completed: t.DoneAt,
|
||||
// Organizer: &t.CreatedBy, // Disabled until we figure out how this works
|
||||
Priority: t.Priority,
|
||||
StartUnix: t.StartDateUnix,
|
||||
EndUnix: t.EndDateUnix,
|
||||
CreatedUnix: t.Created.ToTime().Unix(),
|
||||
UpdatedUnix: t.Updated.ToTime().Unix(),
|
||||
DueDateUnix: t.DueDateUnix,
|
||||
Duration: duration,
|
||||
Priority: t.Priority,
|
||||
Start: t.StartDate,
|
||||
End: t.EndDate,
|
||||
Created: t.Created,
|
||||
Updated: t.Updated,
|
||||
DueDate: t.DueDate,
|
||||
Duration: duration,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -91,36 +91,36 @@ func parseTaskFromVTODO(content string) (vTask *models.Task, err error) {
|
|||
duration, _ := time.ParseDuration(task["DURATION"])
|
||||
|
||||
vTask = &models.Task{
|
||||
UID: task["UID"],
|
||||
Text: task["SUMMARY"],
|
||||
Description: task["DESCRIPTION"],
|
||||
Priority: priority,
|
||||
DueDateUnix: caldavTimeToUnixTimestamp(task["DUE"]),
|
||||
Updated: timeutil.TimeStamp(caldavTimeToUnixTimestamp(task["DTSTAMP"])),
|
||||
StartDateUnix: caldavTimeToUnixTimestamp(task["DTSTART"]),
|
||||
DoneAtUnix: caldavTimeToUnixTimestamp(task["COMPLETED"]),
|
||||
UID: task["UID"],
|
||||
Text: task["SUMMARY"],
|
||||
Description: task["DESCRIPTION"],
|
||||
Priority: priority,
|
||||
DueDate: caldavTimeToTimestamp(task["DUE"]),
|
||||
Updated: caldavTimeToTimestamp(task["DTSTAMP"]),
|
||||
StartDate: caldavTimeToTimestamp(task["DTSTART"]),
|
||||
DoneAt: caldavTimeToTimestamp(task["COMPLETED"]),
|
||||
}
|
||||
|
||||
if task["STATUS"] == "COMPLETED" {
|
||||
vTask.Done = true
|
||||
}
|
||||
|
||||
if duration > 0 && vTask.StartDateUnix > 0 {
|
||||
vTask.EndDateUnix = vTask.StartDateUnix + int64(duration.Seconds())
|
||||
if duration > 0 && vTask.StartDate > 0 {
|
||||
vTask.EndDate = vTask.StartDate + int64(duration.Seconds())
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func caldavTimeToUnixTimestamp(tstring string) int64 {
|
||||
func caldavTimeToTimestamp(tstring string) timeutil.TimeStamp {
|
||||
if tstring == "" {
|
||||
return 0
|
||||
}
|
||||
|
||||
t, err := time.Parse(caldav.DateFormat, tstring)
|
||||
if err != nil {
|
||||
log.Warningf("Error while parsing caldav time %s to unix time: %s", tstring, err)
|
||||
log.Warningf("Error while parsing caldav time %s to TimeStamp: %s", tstring, err)
|
||||
return 0
|
||||
}
|
||||
return t.Unix()
|
||||
return timeutil.FromTime(t)
|
||||
}
|
||||
|
|
|
@ -55,9 +55,9 @@ type User struct {
|
|||
PasswordResetToken string `xorm:"varchar(450) null" json:"-"`
|
||||
EmailConfirmToken string `xorm:"varchar(450) null" json:"-"`
|
||||
|
||||
// A unix timestamp when this task was created. You cannot change this value.
|
||||
// A timestamp when this task was created. You cannot change this value.
|
||||
Created timeutil.TimeStamp `xorm:"created not null" json:"created"`
|
||||
// A unix timestamp when this task was last updated. You cannot change this value.
|
||||
// A timestamp when this task was last updated. You cannot change this value.
|
||||
Updated timeutil.TimeStamp `xorm:"updated not null" json:"updated"`
|
||||
|
||||
web.Auth `xorm:"-" json:"-"`
|
||||
|
|
Loading…
Reference in New Issue