summaryrefslogtreecommitdiff
path: root/model.go
diff options
context:
space:
mode:
Diffstat (limited to 'model.go')
-rw-r--r--model.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/model.go b/model.go
index 96be9e4..b8d174c 100644
--- a/model.go
+++ b/model.go
@@ -2,13 +2,14 @@ package main
import (
"errors"
+ "log"
"regexp"
"time"
)
type Entry struct {
Id int
- Date time.Time
+ Date Date
From *Time
To *Time
Tag *string
@@ -34,6 +35,18 @@ var (
ErrInvalidDate = errors.New("Invalid date string")
)
+func NewEntry(date Date) *Entry {
+ return &Entry{
+ Id: -1,
+ From: nil,
+ Date: date,
+ To: nil,
+ Tag: nil,
+ Comment: "",
+ }
+
+}
+
func TimeFromStd(time time.Time) Time {
return Time(time.Format("15:04"))
}
@@ -67,3 +80,11 @@ func DateFromString(str string) (*Date, error) {
date := Date(str)
return &date, nil
}
+
+func (d Date) ToStd() time.Time {
+ t, err := time.Parse("2006-01-02", string(d))
+ if err != nil {
+ log.Fatal(err)
+ }
+ return t
+}