Skip to content

Commit

Permalink
Rename iso_date to local_date
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulrich Lissé committed Apr 4, 2019
1 parent 51ee0f9 commit adec9dd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
34 changes: 0 additions & 34 deletions date/iso_date.go

This file was deleted.

34 changes: 34 additions & 0 deletions date/local_date.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package date

import "time"

const ISO8601 = "2006-01-02"

type LocalDate struct {
time time.Time
}

func Today() LocalDate {
return From(time.Now().Local())
}

func From(t time.Time) LocalDate {
return LocalDate{time: t}
}

func Parse(s string) (LocalDate, error) {
t, err := time.ParseInLocation(ISO8601, s, time.Local)
if err != nil {
return LocalDate{}, err
}

return From(t), nil
}

func (d LocalDate) Add(years int, months int, days int) LocalDate {
return LocalDate{time: d.time.AddDate(years, months, days)}
}

func (d LocalDate) String() string {
return d.time.Format(ISO8601)
}
File renamed without changes.
8 changes: 4 additions & 4 deletions mite/time_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type TimeEntry struct {
Id string
Note string
Date date.Date
Date date.LocalDate
Duration time.Duration
ProjectId string
ProjectName string
Expand All @@ -20,7 +20,7 @@ type TimeEntry struct {
}

type TimeEntryCommand struct {
Date *date.Date
Date *date.LocalDate
Duration *time.Duration
Note string
ProjectId string
Expand Down Expand Up @@ -49,8 +49,8 @@ func (c *TimeEntryCommand) toRequest() *timeEntryRequest {
}

type TimeEntryQuery struct {
From *date.Date
To *date.Date
From *date.LocalDate
To *date.LocalDate
Direction string
}

Expand Down

0 comments on commit adec9dd

Please sign in to comment.