Skip to content

BUG: Timestamp.toObject() returning zeroed value #222

Description

@kyleshepherd

In the latest version, 3.21.4, the Timestamp.toObject() function isn't working correctly.

Previously it would return the timestamp as an object with keys for seconds and milliseconds. However now it is returning zero values for both.

This is a function where I noticed the issue, I've added some logging which pointed out toObject() as being the problem.

function dateToTs(date: Date): Timestamp {
  const ts = new Timestamp();
  ts.fromDate(date);
  console.log(
    "date:",
    date,
    "timestamp:",
    ts.getSeconds(),
    ts.getNanos(),
    ts.toObject(),
  );
  return ts;
}

See the screenshot below for the resulting console log, where you can see the seconds and milliseconds are set, but the toObject return is zeroed
image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions