From 8bfd8a648e23be27aa72bf56573735c6d96e2cd4 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Tue, 15 Oct 2024 16:25:45 +0200 Subject: [PATCH] Add function to create a new date construct --- date.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/date.go b/date.go index 486a754..008fb3e 100644 --- a/date.go +++ b/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)) -}