Skip to content

Commit

Permalink
fix parseTimestamp number
Browse files Browse the repository at this point in the history
fixes: #32
  • Loading branch information
DenisCarriere committed May 31, 2024
1 parent 83c9c3c commit 3f0b680
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Additionally, `*.clock`, `*.session` & `*.cursor` files are generated to keep tr
eth.substreams.pinax.network-3b180e1d2390afef1f22651581304e04245ba001-graph_out-block_meta.csv
eth.substreams.pinax.network-3b180e1d2390afef1f22651581304e04245ba001-graph_out.clock
eth.substreams.pinax.network-3b180e1d2390afef1f22651581304e04245ba001-graph_out.cursor
eth.substreams.pinax.network-3b180e1d2390afef1f22651581304e04245ba001-graph_out.session
```

### CLI Help
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.3.1",
"version": "0.3.2",
"name": "substreams-sink-csv",
"description": "Substreams Sink CSV",
"type": "module",
Expand Down
11 changes: 10 additions & 1 deletion src/applyReservedFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ export function applyReservedFields( values: Record<string, unknown>, meta: Meta
if ( !values["timestamp"] ) values["timestamp"] = timestamp;

// exception parsing timestamp
if ( values["timestamp"] ) values["timestamp"] = parseTimestamp(Timestamp.fromDate(new Date(values["timestamp"] as string)));
if ( values["timestamp"] ) {
// parse UTC string to timestamp
if ( !isNumber(values["timestamp"]) ) {
values["timestamp"] = parseTimestamp(Timestamp.fromDate(new Date(values["timestamp"] as string)));
}
}
else values["timestamp"] = timestamp;

return values;
}

function isNumber(value: unknown): value is number {
return !isNaN(Number(value));
}

0 comments on commit 3f0b680

Please sign in to comment.