Skip to content

Commit

Permalink
Add timestamp nanoseconds field
Browse files Browse the repository at this point in the history
  • Loading branch information
D4nte committed Feb 24, 2022
1 parent b167b1b commit 60168cc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lib/waku_message/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ export class WakuMessage {
{
payload: _payload,
timestampDeprecated: timestamp.valueOf() / 1000,
// nanoseconds https://rfc.vac.dev/spec/14/
timestamp: timestamp.valueOf() * 1000,
version,
contentTopic,
},
Expand Down Expand Up @@ -270,6 +272,11 @@ export class WakuMessage {
}

get timestamp(): Date | undefined {
if (this.proto.timestamp) {
// nanoseconds https://rfc.vac.dev/spec/14/
return new Date(this.proto.timestamp / 1000);
}

if (this.proto.timestampDeprecated) {
return new Date(this.proto.timestampDeprecated * 1000);
}
Expand Down

0 comments on commit 60168cc

Please sign in to comment.