Skip to content

FR: Add valueOf() to Timestamp instances #2632

Description

@davidwkeith

[REQUIRED] Describe your environment

  • Operating System version: macOS 10.15.2 (19C57)
  • Browser version: Node v1.21.1
  • Firebase SDK version: 7.13.0
  • Firebase Product: Firestore

[REQUIRED] Describe the problem

Unable to compare Timestamp instances with native comparators. Javascript calls valueOf() on the object and uses the results of that to do native comparisons.

Steps to reproduce:

Attempt to compare Timestamps directly.

Relevant Code:

firebase = require('firebase-admin')
a = new firebase.firestore.Timestamp(1, 1)
b = new firebase.firestore.Timestamp(2, 2)
console.log(a < b) // false
console.log(b < a) // false

Workaround

Of course you can simply call toMillis() and compare those, but having it auto handled would be better.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions