Dates are now of type time.Time.
This commit is contained in:
parent
729e58fdca
commit
309044f651
@ -4,6 +4,7 @@ import (
|
||||
"database/sql"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.arav.top/Arav/justguestbook/guestbook"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
@ -137,9 +138,14 @@ func (d *SQLiteDatabase) Entries(page, pageSize int64) (entries []*guestbook.Ent
|
||||
}
|
||||
|
||||
if reply_message.Valid /* reply_created is also valid if reply is */ {
|
||||
date, err := time.Parse(guestbook.DateFormat, reply_created.String)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
entry.Reply = &guestbook.Reply{
|
||||
ID: entry.ID,
|
||||
Created: reply_created.String,
|
||||
Created: date,
|
||||
Message: reply_message.String}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type Entry struct {
|
||||
ID int64 `json:"entry_id"`
|
||||
Created string `json:"created"`
|
||||
Created time.Time `json:"created"`
|
||||
Name string `json:"name"`
|
||||
Website string `json:"website,omitempty"`
|
||||
Message string `json:"message"`
|
||||
@ -21,7 +21,7 @@ func NewEntry(name, message, website string, hideWebsite bool) (*Entry, error) {
|
||||
}
|
||||
|
||||
return &Entry{
|
||||
Created: time.Now().UTC().Format(DateFormat),
|
||||
Created: time.Now().UTC(),
|
||||
Name: name,
|
||||
Website: website,
|
||||
HideWebsite: hideWebsite,
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type Reply struct {
|
||||
ID int64 `json:"-"`
|
||||
Created string `json:"created,omitempty"`
|
||||
Created time.Time `json:"created,omitempty"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
@ -18,6 +18,6 @@ func NewReply(entryID int64, message string) (*Reply, error) {
|
||||
|
||||
return &Reply{
|
||||
ID: entryID,
|
||||
Created: time.Now().UTC().Format(DateFormat),
|
||||
Created: time.Now().UTC(),
|
||||
Message: message}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user