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

adding helper function to create a timestamp #583

Merged

Conversation

flothjl
Copy link
Contributor

@flothjl flothjl commented Oct 28, 2023

Addresses #570

  • Adds and exports a helper function to create timestamps to use in dwn messages.

@codesandbox
Copy link

codesandbox bot commented Oct 28, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2023

Codecov Report

Merging #583 (609b77b) into main (fb08183) will decrease coverage by 0.12%.
Report is 2 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #583      +/-   ##
==========================================
- Coverage   97.81%   97.69%   -0.12%     
==========================================
  Files          66       66              
  Lines        7964     7987      +23     
  Branches     1157     1155       -2     
==========================================
+ Hits         7790     7803      +13     
- Misses        168      178      +10     
  Partials        6        6              
Files Coverage Δ
src/index.ts 100.00% <100.00%> (ø)
src/utils/time.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@flothjl flothjl marked this pull request as ready for review October 28, 2023 01:32
Copy link
Member

@csuwildcat csuwildcat left a comment

Choose a reason for hiding this comment

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

Does the method allow for calling with no parameters and returning an auto-generated timestamp too?

@flothjl
Copy link
Contributor Author

flothjl commented Oct 30, 2023

@csuwildcat currently no. There is another helper method getCurrentTimeInHighPrecision

@LiranCohen
Copy link
Member

@csuwildcat when you say auto-generated do you mean of the current time as @flothjl mentioned or a random timestamp for testing?

We do have a crude randomTimestamp in the TestDataGenerator class. Maybe the intent of these can be combined?

https://github.com/TBD54566975/dwn-sdk-js/blob/main/tests/utils/test-data-generator.ts#L834-L844

@csuwildcat
Copy link
Member

I meant getting the current time in this format. I know the records create/update code does this automatically if omitted, just might be worth it exposing auto-generated/- filled timestamps if you call with no params or less than full params. Could be a waste of time though, because the most important thing is just having a function to cast values into the right format.

@LiranCohen
Copy link
Member

@csuwildcat ah yeah, in that case I think keeping the current getCurrentTimeInHighPrecision makes more sense, that way the two different functions have clearer intents without having the optional values.

@flothjl
Copy link
Contributor Author

flothjl commented Oct 30, 2023

@LiranCohen good call out on randomTimestamp. I updated randomTimestamp to use the new helper method.

src/utils/time.ts Outdated Show resolved Hide resolved
src/utils/time.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@thehenrytsai thehenrytsai left a comment

Choose a reason for hiding this comment

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

🙏 🔥 🎖️

@thehenrytsai thehenrytsai added hacktoberfest For the hacking month of October hacktoberfest-accepted Accepted PRs for the hacking month of October labels Oct 30, 2023
@thehenrytsai thehenrytsai merged commit c0f2a95 into decentralized-identity:main Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest For the hacking month of October hacktoberfest-accepted Accepted PRs for the hacking month of October
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants