fixing date format on article page
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"crowsnest/internal/model"
|
"crowsnest/internal/model"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ArticlePageViewModelRepository struct {
|
type ArticlePageViewModelRepository struct {
|
||||||
@@ -22,7 +23,8 @@ func (m *ArticlePageViewModelRepository) ById(id int64) (*model.ArticlePageViewM
|
|||||||
rows := m.DB.QueryRow(stmt, id)
|
rows := m.DB.QueryRow(stmt, id)
|
||||||
|
|
||||||
a := &model.ArticlePageViewModel{}
|
a := &model.ArticlePageViewModel{}
|
||||||
if err := rows.Scan(&a.SourceUrl, &a.PublishDate, &a.Title, &a.Content, &a.Summary); err != nil {
|
var date time.Time
|
||||||
|
if err := rows.Scan(&a.SourceUrl, &date, &a.Title, &a.Content, &a.Summary); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +35,8 @@ func (m *ArticlePageViewModelRepository) ById(id int64) (*model.ArticlePageViewM
|
|||||||
} else {
|
} else {
|
||||||
a.ShortSource = ""
|
a.ShortSource = ""
|
||||||
}
|
}
|
||||||
|
// publish date
|
||||||
|
a.PublishDate = date.Format("02.01.2006 15:04")
|
||||||
|
|
||||||
return a, nil
|
return a, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user