Add function to create a new date construct
This commit is contained in:
parent
7de921b1b5
commit
8bfd8a648e
12
date.go
12
date.go
@ -10,6 +10,14 @@ type Date struct {
|
||||
DateTime string
|
||||
}
|
||||
|
||||
func DateTime(t time.Time) string {
|
||||
return string(t.Format(time.RFC3339))
|
||||
}
|
||||
|
||||
func NewDate(t time.Time) *Date {
|
||||
return &Date{DateTime: DateTime(t)}
|
||||
}
|
||||
|
||||
func (d *Date) Check() error {
|
||||
if d.DateTime == "" {
|
||||
return errors.New("date time element of date is empty")
|
||||
@ -17,7 +25,3 @@ func (d *Date) Check() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func DateTime(t time.Time) string {
|
||||
return string(t.Format(time.RFC3339))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user