1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

go mod vendor update

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer
2019-12-14 08:52:34 -08:00
parent 703619bf0a
commit 3d4059de02
665 changed files with 104373 additions and 59789 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"io"
"net/http"
"time"
)
// Task is a model of todoist project entity
@@ -25,7 +26,7 @@ type Task struct {
type Due struct {
String string `json:"string"`
Date string `json:"date"`
Datetime CustomTime `json:"datetime"`
Datetime time.Time `json:"datetime,omitempty"`
Timezone string `json:"timezone"`
}

View File

@@ -6,7 +6,6 @@ import (
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"
)
@@ -56,33 +55,6 @@ func makeRequest(method, endpoint string, data interface{}) (*http.Response, err
return res, nil
}
const ctLayout = "2006-01-02T15:04:05+00:00"
// CustomTime had a custom json date format
type CustomTime struct {
time.Time
}
// UnmarshalJSON convert from []byte to CustomTime
func (ct *CustomTime) UnmarshalJSON(b []byte) (err error) {
s := strings.Trim(string(b), "\"")
if s == "null" {
ct.Time = time.Time{}
return nil
}
ct.Time, err = time.Parse(ctLayout, s)
return err
}
// MarshalJSON convert CustomTime to []byte
func (ct CustomTime) MarshalJSON() ([]byte, error) {
if ct.Time.IsZero() {
return []byte("null"), nil
}
return []byte(`"` + ct.Time.Format(ctLayout) + `"`), nil
}
type taskSave struct {
Content string `json:"content"`
ProjectID int `json:"project_id,omitempty"`
@@ -90,7 +62,7 @@ type taskSave struct {
LabelIDs []int `json:"label_ids,omitempty"`
Priority int `json:"priority,omitempty"`
DueString string `json:"due_string,omitempty"`
DueDateTime CustomTime `json:"due_datetime,omitempty"`
DueDateTime time.Time `json:"due_datetime,omitempty"`
DueLang string `json:"due_lang,omitempty"`
}