go-gorm / go-gorm/datatypes

Use civil.Date for date fields

Open
#155 1 comment 5 reactions 1 assignee Claimed by @jinzhu View on GitHub
Dominant language
Go
Stars
831
Forks
124
PR merge metrics
No merged PRs in 30d

Description

## Describe the feature

Rather than using `time.Time` for sql date fields, shouldn't we rather use `civil.Date` from https://pkg.go.dev/cloud.google.com/go/civil. This latter type seems to be the standard way to handle dates in go.

## Motivation

If one uses time.Time to represent dates, the time part is set to all 0's. If the end user isn't aware that the time part should be ignored, this can cause confusion, and even create errors if it's interpreted in a GMT+ve timezone.

## Related Issues

## Other

I tried defining a custom struct that uses civil.Date fields, and scanning the database result into this struct. This resulted in a date with value `0000-00-00`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.