atom/date.go

28 lines
388 B
Go
Raw Normal View History

2024-10-13 17:19:40 +02:00
package atomfeed
import (
"errors"
"time"
)
type Date struct {
*CommonAttributes
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)}
}
2024-10-13 17:19:40 +02:00
func (d *Date) Check() error {
if d.DateTime == "" {
return errors.New("date time element of date is empty")
}
return nil
}