8000 toEpochMilli() only on Instant and not ZonedDateTime? · Issue #754 · js-joda/js-joda · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

toEpochMilli() only on Instant and not ZonedDateTime? #754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JonDum opened this issue Mar 7, 2025 · 1 comment
Open

toEpochMilli() only on Instant and not ZonedDateTime? #754

JonDum opened this issue Mar 7, 2025 · 1 comment

Comments

@JonDum
Copy link
Contributor
JonDum commented Mar 7, 2025

Hi,

I was just wondering if there's a technical reason why Instant has toEpochMilli() but ZonedDateTime does not?

If there's no technical reason would you be open to a PR to add toEpochMilli() in addition to toEpochSecond()?

Rationale: I primarily use ZonedDateTime's and there's about a thousand places in my code base where I have to zdt.toEpochSecond() * 1e3 (which isn't that pretty and kind of fragile) or zdt.toInstant().toEpochMilli() which has a lot of unnecessary CPU cycles converting to Instant.

These calcs run millions of times per second so CPU cycles are kind of important (similar to perf impact I had from #734)

@pithu
Copy link
Member
pithu commented Mar 8, 2025

Hi @JonDum, why not, for convenience, but i would not expect any performance improvements.

But please do not forget to add some tests and the typescript typings.

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

No branches or pull requests

2 participants
0