Fix unnecessary early overflow in NewUTCSpliceTime, add tests #89
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While looking through the code for functions/methods that maybe should have a test, I noticed that
NewUTCSpliceTime
overflows when the gpsepoch input plus the offset between unix epoch and gps epoch exceeds uint32. While this only happens in the year 2106 and it is questionable (but not ruled out 😬 ) that SCTE35 is still in use then, I found it wrong to leave it like that. Fixed that, now it works with all values for gpsepoch, which only overflows in the year 2116 when the range really ends (so roughly 10 years later). Also internally the time was not stored as UTC. While that probably makes no difference, I fixed that too.The GPSSeconds method of UTCSpliceTime likewise had a overflow in the year 2106. Here it did not affect the result, as the subsequent subtraction in uint32 number space still resulted in the correct result, but again it felt wrong, to leave it like that.
Also added tests.