date and time zero value
This commit is contained in:
parent
e4faf75aeb
commit
e9ce251737
|
@ -167,7 +167,7 @@ func (d Date) DaysBetween(d2 Date) int {
|
|||
|
||||
func (d Date) String() string {
|
||||
if d.t.IsZero() {
|
||||
return "no date"
|
||||
return ""
|
||||
}
|
||||
|
||||
return strings.ToLower(d.t.Format(DateFormat))
|
||||
|
|
|
@ -230,7 +230,7 @@ func TestDateString(t *testing.T) {
|
|||
{
|
||||
name: "zero",
|
||||
date: item.NewDate(0, 0, 0),
|
||||
exp: "no date",
|
||||
exp: "",
|
||||
},
|
||||
{
|
||||
name: "normal",
|
||||
|
|
|
@ -102,7 +102,7 @@ func TestTaskItem(t *testing.T) {
|
|||
expItem: item.Item{
|
||||
Kind: item.KindTask,
|
||||
Updated: time.Time{},
|
||||
Body: `{"duration":"0s","title":"","time":"00:00"}`,
|
||||
Body: `{"duration":"0s","title":"","time":""}`,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -44,6 +44,10 @@ func NewTimeFromString(timeStr string) Time {
|
|||
}
|
||||
|
||||
func (t *Time) String() string {
|
||||
if t.t.IsZero() {
|
||||
return ""
|
||||
}
|
||||
|
||||
return t.t.Format(TimeFormat)
|
||||
}
|
||||
|
||||
|
|
|
@ -44,11 +44,16 @@ func TestTimeFromString(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "empty",
|
||||
exp: "00:00",
|
||||
exp: "",
|
||||
},
|
||||
{
|
||||
name: "invalid",
|
||||
str: "invalid",
|
||||
exp: "",
|
||||
},
|
||||
{
|
||||
name: "00:00",
|
||||
str: "00:00",
|
||||
exp: "00:00",
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue