Skip to content

Conversation

ThanhPham1003
Copy link

Closes #60

  • Added utc_timestamp tag to generate time.Time values in UTC.
  • Implemented UTCTimestamp and UTCTimestampValue in datetime.go.
  • Added test in datetime_test.go following TestUnixTimeValueValid style.

@rubemlrm rubemlrm self-requested a review May 27, 2025 09:43
@rubemlrm
Copy link
Contributor

@ThanhPham1003 try update your branch, our pipeline was having some issues that were provoking failures for the testing steps.

}
val, err := d.UTCTimestampValue(reflect.ValueOf(&ref.some).Elem())
if err != nil {
t.Error("function UTCTimestampValue need return valid value")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Error("function UTCTimestampValue need return valid value")
t.Error("function UTCTimestampValue needs to return a valid value")

Comment on lines +277 to +278
if time.Now().Unix() <= result.Unix() {
t.Error("UTCTimestamp should return time <= now")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this condition easier to understand and consistent with the error message.

Suggested change
if time.Now().Unix() <= result.Unix() {
t.Error("UTCTimestamp should return time <= now")
if result.Unix() > time.Now().Unix() {
t.Error("UTCTimestamp should return time <= now")

We should use > instead of >= because if result == now, the current logic would still trigger an error, even though it satisfies the expectation (result <= now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to init time.Time values with UTC timezone.
3 participants