[GH-ISSUE #322] why is timestamp an integer? #828

Closed
opened 2026-03-15 10:37:57 +03:00 by kerem · 5 comments
Owner

Originally created by @kilobyte on GitHub (Sep 28, 2018).
Original GitHub issue: https://github.com/asciinema/asciinema/issues/322

While adding asciicast support to termrec, I noticed that the "timestamp" field is supposed to be an integer — inconsistently with "duration" and event timestamps. Is there a reason for this?

It doesn't matter much in most cases, as humans care mostly about recording date — but I can think of scenarios where not losing the precision would be nice.

(And my direct reason is that it's an odd case in the testsuite for round-tripping between ttyrec and asciicast :p.)

Originally created by @kilobyte on GitHub (Sep 28, 2018). Original GitHub issue: https://github.com/asciinema/asciinema/issues/322 While adding asciicast support to termrec, I noticed that the "timestamp" field is supposed to be an integer — inconsistently with "duration" and event timestamps. Is there a reason for this? It doesn't matter much in most cases, as humans care mostly about recording _date_ — but I can think of scenarios where not losing the precision would be nice. (And my direct reason is that it's an odd case in the testsuite for round-tripping between ttyrec and asciicast :p.)
kerem closed this issue 2026-03-15 10:38:02 +03:00
Author
Owner

@ku1ik commented on GitHub (Nov 16, 2018):

Hehe, I can see round-tripping problem :)

Yeah, the duration and event timestamps are floats, obviously.

The timestamp field is like you figured only something that would be turned into a date for humans, so we never thought we would need sub-second precision here. So no, there's no specific reason for this.

Since changing this would be a breaking change I'd rather not do this to v2. In practice it would probably be ok-ish, since neither asciinema play nor asciinema web player use this field for anything, and they're written in dynamic languages, which would handle that the same way. I said "ok-ish" as I don't know all the other tools people built around this format (I know of svg-term-cli, and a bunch of others), and whether they would work.

That could definitely be changed in v3 of the file format, although I don't see anything else which needs fixing in v2 to introduce v3 anytime soon.

<!-- gh-comment-id:439325520 --> @ku1ik commented on GitHub (Nov 16, 2018): Hehe, I can see round-tripping problem :) Yeah, the duration and event timestamps are floats, obviously. The `timestamp` field is like you figured only something that would be turned into a date for humans, so we never thought we would need sub-second precision here. So no, there's no specific reason for this. Since changing this would be a breaking change I'd rather not do this to v2. In practice it would probably be ok-ish, since neither `asciinema play` nor asciinema web player use this field for anything, and they're written in dynamic languages, which would handle that the same way. I said "ok-ish" as I don't know all the other tools people built around this format (I know of svg-term-cli, and a bunch of others), and whether they would work. That could definitely be changed in v3 of the file format, although I don't see anything else which needs fixing in v2 to introduce v3 anytime soon.
Author
Owner

@ku1ik commented on GitHub (Nov 17, 2018):

Actually it was supposed to be float: https://github.com/asciinema/asciinema/blob/develop/doc/asciicast-v2.md#duration

So it's been wrongly saved as integer :|

<!-- gh-comment-id:439623572 --> @ku1ik commented on GitHub (Nov 17, 2018): Actually it was supposed to be float: https://github.com/asciinema/asciinema/blob/develop/doc/asciicast-v2.md#duration So it's been wrongly saved as integer :|
Author
Owner

@kilobyte commented on GitHub (Nov 17, 2018):

termrec already accepts floats so that's nice. Should it produce them when writing an asciicast file?

<!-- gh-comment-id:439624114 --> @kilobyte commented on GitHub (Nov 17, 2018): **termrec** already accepts floats so that's nice. Should it produce them when writing an asciicast file?
Author
Owner

@ku1ik commented on GitHub (Nov 17, 2018):

@kilobyte yes, let's go with floats here, since that's what was the intent, and what the v2 format doc says. I'll fix that in asciinema recorder too.

<!-- gh-comment-id:439625469 --> @ku1ik commented on GitHub (Nov 17, 2018): @kilobyte yes, let's go with floats here, since that's what was the intent, and what the v2 format doc says. I'll fix that in asciinema recorder too.
Author
Owner

@ku1ik commented on GitHub (Nov 17, 2018):

@kilobyte ah, sorry. I looked wrong. duration (which I linked above by mistake) is supposed to be float but timestamp is documented as integer, like I wrote yesterday. Sorry for confusion. In that case I'd rather stay with int...

<!-- gh-comment-id:439625781 --> @ku1ik commented on GitHub (Nov 17, 2018): @kilobyte ah, sorry. I looked wrong. `duration` (which I linked above by mistake) is supposed to be float but `timestamp` is documented as integer, like I wrote yesterday. Sorry for confusion. In that case I'd rather stay with int...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asciinema#828
No description provided.