Skip to content

Commit

Permalink
feat: add nowInBigIntNanoSeconds to utils (#756)
Browse files Browse the repository at this point in the history
# Motivation

We actually use `nowInBigIntNanoSeconds` everywhere so let's add it to
utils.

# Changes

- Copy function `nowInBigIntNanoSeconds` to `@dfinity/utils`.

---------

Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
peterpeterparker and github-actions[bot] authored Nov 20, 2024
1 parent 013f9c1 commit 1782ef4
Show file tree
Hide file tree
Showing 4 changed files with 253 additions and 210 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- Added `memoToNeuronSubaccount` and `memoToNeuronAccountIdentifier`.
- Support new neuron field `voting_power_refreshed_timestamp_seconds`.
- Add `nowInBigIntNanoSeconds` to `@dfinity/utils`, a trivial function that is actually used across all our dapps.

## Build

Expand Down
11 changes: 11 additions & 0 deletions packages/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ npm i @dfinity/agent @dfinity/candid @dfinity/principal
- [decodeBase32](#gear-decodebase32)
- [bigEndianCrc32](#gear-bigendiancrc32)
- [secondsToDuration](#gear-secondstoduration)
- [nowInBigIntNanoSeconds](#gear-nowinbigintnanoseconds)
- [debounce](#gear-debounce)
- [toNullable](#gear-tonullable)
- [fromNullable](#gear-fromnullable)
Expand Down Expand Up @@ -302,6 +303,16 @@ Parameters:

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/date.utils.ts#L43)

#### :gear: nowInBigIntNanoSeconds

Returns the current timestamp in nanoseconds as a `bigint`.

| Function | Type |
| ------------------------ | -------------- |
| `nowInBigIntNanoSeconds` | `() => bigint` |

[:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/date.utils.ts#L115)

#### :gear: debounce

| Function | Type |
Expand Down
Loading

0 comments on commit 1782ef4

Please sign in to comment.