-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Labels
kind/enhancementstatus/acceptedAccepted and awaiting implementationAccepted and awaiting implementation
Milestone
Description
What is the problem you're trying to solve
Lines 148 to 157 in 831b9a9
| // The value of `image.CreatedAt` passed from the caller is discarded here. | |
| // Ideally we should return an error when the value is already set. | |
| // However, as `image.CreatedAt` is defined as a non-pointer `time.Time`, we can't compare it to nil. | |
| // And we can't compare it to `time.Time{}` either, as `time.Time{}` is a proper timestamp (1970-01-01 00:00:00). | |
| if tm := epoch.FromContext(ctx); tm != nil { | |
| image.CreatedAt = tm.UTC() | |
| } else { | |
| image.CreatedAt = time.Now().UTC() | |
| } | |
| image.UpdatedAt = image.CreatedAt |
Currently, Create(ctx, img) does not consume img.CreatedAt value by design.
This issue can be currently worked around by ctx = epoch.WithSourceDateEpoch(ctx, customCreatedAt), but this should be possible without depending on ctx too.
Describe the solution you'd like
Consume the value of img.CreatedAt when it is explicitly set.
This change requires changing the type of CreatedAt form time.Time to *time.Time, or, add another property like CreatedAtIsSet, so as to differentiate "not set" from "1970-01-01 00:00:00".
Additional context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind/enhancementstatus/acceptedAccepted and awaiting implementationAccepted and awaiting implementation
Type
Projects
Status
Todo