Skip to content

AsTime() on a nil pointer converts to Jan. 1st, 1970 at midnight UTC #1846

Open
@antlai-temporal

Description

@antlai-temporal

The protobuf library maps a nil timestamp to Jan. 1st, 1970 at midnight UTC and makes IsZero() false. One side effect is that the cli cardOmitEmpty and omitEmpty no longer filter timestamps that have not been initialized. This is also a problem for users of the raw grpc API.

(*timestamppb.Timestamp)(nil).AsTime().IsZero() // FALSE!

The solution is to check with IsValid() before calling AsTime()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions