From d05dee89a8f9d691dd0b1cf95f5dbef57f3618e5 Mon Sep 17 00:00:00 2001 From: Leland Garofalo Date: Thu, 7 Mar 2024 15:29:22 -0800 Subject: [PATCH] feat: update time formats --- internal/db/types.go | 24 ++++++++++++------------ internal/resources/types.go | 9 +++++---- internal/services/manager.go | 10 +++++----- internal/services/types.go | 10 +++++----- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/internal/db/types.go b/internal/db/types.go index 9b5d65aa..c04f9dd1 100644 --- a/internal/db/types.go +++ b/internal/db/types.go @@ -35,7 +35,7 @@ type Service struct { Fee sql.NullString ApplicationProcess sql.NullString ResourceId sql.NullInt32 - VerifiedAt sql.NullTime + VerifiedAt *time.Time Email sql.NullString Status sql.NullInt32 Certified bool @@ -46,7 +46,7 @@ type Service struct { ContactId sql.NullInt32 FundingId sql.NullInt32 AlternateName sql.NullString - CertifiedAt sql.NullTime + CertifiedAt *time.Time Featured sql.NullBool SourceAttribution sql.NullInt32 InternalNote sql.NullString @@ -80,29 +80,29 @@ type Address struct { Name sql.NullString Description sql.NullString Transportation sql.NullString - CreatedAt sql.NullTime - UpdatedAt sql.NullTime + CreatedAt time.Time + UpdatedAt time.Time } type Eligibility struct { Id int Name sql.NullString FeatureRank sql.NullInt32 - CreatedAt sql.NullTime - UpdatedAt sql.NullTime + CreatedAt time.Time + UpdatedAt time.Time } type Instruction struct { Id int Instruction sql.NullString - CreatedAt sql.NullTime - UpdatedAt sql.NullTime + CreatedAt time.Time + UpdatedAt time.Time } type Document struct { Id int Name sql.NullString Url sql.NullString Description sql.NullString - CreatedAt sql.NullTime - UpdatedAt sql.NullTime + CreatedAt time.Time + UpdatedAt time.Time } type Resource struct { Id int @@ -114,9 +114,9 @@ type Resource struct { Name string ShortDescription sql.NullString Status sql.NullString - VerifiedAt sql.NullString + VerifiedAt *time.Time Website sql.NullString - CertifiedAt sql.NullTime + CertifiedAt *time.Time Featured sql.NullBool SourceAttribution sql.NullString InternalNote sql.NullString diff --git a/internal/resources/types.go b/internal/resources/types.go index 1bf35926..18aab22e 100644 --- a/internal/resources/types.go +++ b/internal/resources/types.go @@ -68,14 +68,15 @@ func FromDBType(dbResource *db.Resource) *Resource { status := Status(dbResource.Status.String) resource.Status = &status } - if dbResource.VerifiedAt.Valid { - resource.VerifiedAt = &dbResource.VerifiedAt.String + if dbResource.VerifiedAt != nil { + verifiedAt := dbResource.VerifiedAt.Format("2006-01-02T15:04:05.000Z") + resource.VerifiedAt = &verifiedAt } if dbResource.Website.Valid { resource.Website = &dbResource.Website.String } - if dbResource.CertifiedAt.Valid { - certifiedAt := dbResource.CertifiedAt.Time.Format("2006-01-02T15:04:05.000Z07:00") + if dbResource.CertifiedAt != nil { + certifiedAt := dbResource.CertifiedAt.Format("2006-01-02T15:04:05.000Z") resource.CertifiedAt = &certifiedAt } if dbResource.Featured.Valid { diff --git a/internal/services/manager.go b/internal/services/manager.go index 82ca0c7c..35e0b2e2 100644 --- a/internal/services/manager.go +++ b/internal/services/manager.go @@ -108,7 +108,7 @@ func convertServiceToResourceService(dbService *db.Service) *resources.ResourceS Certified: dbService.Certified, Id: dbService.Id, SourceAttribution: SourceAttribution(int(dbService.SourceAttribution.Int32)), - UpdatedAt: dbService.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00"), + UpdatedAt: dbService.UpdatedAt.Format("2006-01-02T15:04:05.000Z"), } if dbService.AlternateName.Valid { service.AlternateName = &dbService.AlternateName.String @@ -140,15 +140,15 @@ func convertServiceToResourceService(dbService *db.Service) *resources.ResourceS if dbService.Url.Valid { service.Url = &dbService.Url.String } - if dbService.VerifiedAt.Valid { - verifiedAt := dbService.VerifiedAt.Time.String() + if dbService.VerifiedAt != nil { + verifiedAt := dbService.VerifiedAt.Format("2006-01-02T15:04:05.000Z") service.VerifiedAt = &verifiedAt } if dbService.WaitTime.Valid { service.WaitTime = &dbService.WaitTime.String } - if dbService.CertifiedAt.Valid { - certifiedAt := dbService.CertifiedAt.Time.String() + if dbService.CertifiedAt != nil { + certifiedAt := dbService.CertifiedAt.Format("2006-01-02T15:04:05.000Z") service.CertifiedAt = &certifiedAt } if dbService.Featured.Valid { diff --git a/internal/services/types.go b/internal/services/types.go index 30d946e1..c92fa6e1 100644 --- a/internal/services/types.go +++ b/internal/services/types.go @@ -55,7 +55,7 @@ func FromDBType(dbService *db.Service) *Service { Certified: dbService.Certified, Id: dbService.Id, SourceAttribution: SourceAttribution(int(dbService.SourceAttribution.Int32)), - UpdatedAt: dbService.UpdatedAt.Format("2006-01-02T15:04:05.000Z07:00"), + UpdatedAt: dbService.UpdatedAt.Format("2006-01-02T15:04:05.000Z"), } if dbService.AlternateName.Valid { service.AlternateName = &dbService.AlternateName.String @@ -87,15 +87,15 @@ func FromDBType(dbService *db.Service) *Service { if dbService.Url.Valid { service.Url = &dbService.Url.String } - if dbService.VerifiedAt.Valid { - verifiedAt := dbService.VerifiedAt.Time.String() + if dbService.VerifiedAt != nil { + verifiedAt := dbService.VerifiedAt.Format("2006-01-02T15:04:05.000Z") service.VerifiedAt = &verifiedAt } if dbService.WaitTime.Valid { service.WaitTime = &dbService.WaitTime.String } - if dbService.CertifiedAt.Valid { - certifiedAt := dbService.CertifiedAt.Time.String() + if dbService.CertifiedAt != nil { + certifiedAt := dbService.CertifiedAt.Format("2006-01-02T15:04:05.000Z") service.CertifiedAt = &certifiedAt } if dbService.Featured.Valid {