feat(database): time in UTC #10

Merged
SoXX merged 1 commits from dev/time-in-utc into main 2024-08-29 12:35:10 +00:00
Showing only changes of commit b3ebc23b09 - Show all commits

View File

@ -4,6 +4,7 @@ import (
"context" "context"
"embed" "embed"
"fmt" "fmt"
"time"
"git.anthrove.art/Anthrove/otter-space-sdk/v3/internal/utils" "git.anthrove.art/Anthrove/otter-space-sdk/v3/internal/utils"
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/error" otterError "git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/error"
@ -65,6 +66,9 @@ func Connect(ctx context.Context, config models.DatabaseConfig) error {
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%d sslmode=%s TimeZone=%s", config.Endpoint, config.Username, config.Password, config.Database, config.Port, localSSL, config.Timezone) dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%d sslmode=%s TimeZone=%s", config.Endpoint, config.Username, config.Password, config.Database, config.Port, localSSL, config.Timezone)
sqlDB, err := gorm.Open(postgres.Open(dsn), &gorm.Config{ sqlDB, err := gorm.Open(postgres.Open(dsn), &gorm.Config{
TranslateError: true, TranslateError: true,
NowFunc: func() time.Time {
return time.Now().UTC()
},
}) })
if err != nil { if err != nil {
return utils.HandleError(ctx, span, localLogger, err) return utils.HandleError(ctx, span, localLogger, err)