Skip to content
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

feat: util to convert date to timestamp in nanoseconds #850

Merged
merged 5 commits into from
Feb 26, 2025

Conversation

peterpeterparker
Copy link
Member

Motivation

In dapps it's could happens that date should be converted to nanoseconds. I also plan to add a util (in another PR) that will requires it. Therefore it can be handy to add a utils for such purpose.

Changes

  • New utils toBigIntNanoSeconds
  • Add entry to changelog and correct two unrelated typos

@peterpeterparker peterpeterparker requested review from a team as code owners February 26, 2025 08:21
Copy link
Contributor

github-actions bot commented Feb 26, 2025

size-limit report 📦

Path Size
@dfinity/ckbtc 8.15 KB (0%)
@dfinity/cketh 3.69 KB (0%)
@dfinity/cmc 1.41 KB (0%)
@dfinity/ledger-icrc 4.29 KB (0%)
@dfinity/ledger-icp 15.41 KB (0%)
@dfinity/nns 37.55 KB (0%)
@dfinity/nns-proto 140.99 KB (0%)
@dfinity/sns 17.65 KB (0%)
@dfinity/utils 4.73 KB (+0.36% 🔺)
@dfinity/zod-schemas 626 B (0%)
@dfinity/ic-management 3.22 KB (0%)

Copy link
Contributor

@mstrasinskis mstrasinskis left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@peterpeterparker peterpeterparker merged commit 34d3230 into main Feb 26, 2025
14 checks passed
@peterpeterparker peterpeterparker deleted the feat/tobigintinanoseconds branch February 26, 2025 09:48
peterpeterparker added a commit that referenced this pull request Feb 26, 2025
…r nanoseconds (#851)

# Motivation

I was hesitating between using `toBigIntNanoSeconds` within
`nowInBigIntNanoSeconds` or extracting a constant to avoid code
duplication. The former would require updating the test as well,
therefore went for the later.

Furtheremore, we also unwrap the bigint to avoid unnecessary conversion
as suggested in this
[comment](#850 (comment)).

# Changes

- Extract a local constant `NANOSECONDS_PER_MILLISECOND` for
`BigInt(1e6)`
- `BigInt(1e6)` becomes `1_000_000n`

---------

Signed-off-by: David Dal Busco <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
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.

2 participants