question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Format of the timestamp in timestamp extrinsic?

See original GitHub issue

Hello, I found that for recent blocks (polkadot) the timestamp extrinsic is parsed with extrinsic['call']['call_args']['type'] == 'Moment' and value is some rather big number (e.g. for block 7313001 it is 1634560404001) - clearly it is not a Unix timestamp. How can I parse this number into timestamp?

I’ve used to parse timestamp values as strings in format '%Y-%m-%dT%H:%M:%S.%f', but it worker for timestamps with extrinsic['call']['call_args']['type'] == 'Compact<Moment>'.

Now when the call value is integer, I need to introduce some changes to my code, but I can’t find what format the timestamp value is.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
maayankcommented, Oct 18, 2021

If you don’t care for ms precision then simply divide by 1000 and round down

On Mon, Oct 18, 2021 at 16:32, stolpa4 @.***> wrote:

Hello, I found that for recent blocks (polkadot) the timestamp extrinsic is parsed with extrinsic[‘call’][‘call_args’][‘type’] == ‘Moment’ and value is some rather big number (e.g. for block 7313001 it is 1634560404001) - clearly it is not a Unix timestamp. How can I parse this number into timestamp?

I’ve used to parse timestamp values as strings in format ‘%Y-%m-%dT%H:%M:%S.%f’, but it worker for timestamps with extrinsic[‘call’][‘call_args’][‘type’] == ‘Compact<Moment>’.

Now the parsed value is integer.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

0reactions
arjanzcommented, Nov 9, 2021

After some discussion how to deal with the Moment type it will be consistently treated as an u64 as per the Substrate codebase, also for pre-MetadataV14 runtimes. Conversion to e.g. a datetime will be up to the application.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Timestamps, Time Zones, Time Ranges, and Date Formats
Learn how Sumo Logic manages timestamps, time zones, time ranges, and dates, and the configuration options that are available.
Read more >
timestamp formats - IBM
The format options of timestamp combine the formats of the date and time data types. The default timestamp format is as follows: %yyyy-%mm-%dd...
Read more >
polkadot js - Can we query blocks by (extrinsics) timestamp?
Just want to confirm that the first argument of extrinsic timestamp seems to be the conventional way. See example in Subquery tutorial.
Read more >
Get system time in scope of substrate pallet - Stack Overflow
In the case of pallet-timestamp, this will check that the inherent extrinsic setting the timestamp in the block set a sensible time.
Read more >
Timestamp (Java Platform SE 8 ) - Oracle Help Center
Formats a timestamp in JDBC timestamp escape format. yyyy-mm-dd hh:mm:ss.fffffffff , where ffffffffff indicates nanoseconds. Overrides: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found