Signed Time Span Fat Wire Type
If you've experimented with using the Calculator to do math with the new Date & Time fat wire type, you'll have immediately noticed some counterintuitive results. For example, if you add 00:00:00.000 1/1/1980 to 00:00:00.000 1/1/1990, you get 00:00:00.000 1/1/2000. This is because a Date & Time is represented as a quantity - most likely an unsigned 64 bit integer - of millisecond ticks after the epoch 00:00:00.000 1/1/1970. You can work around this for some cases. But if you try to subtract a later Date & Time from an earlier one, the output fat wire will have a Date & Time that the Splitter can't make head nor tail of.
To fix this, we could have a Signed Time Span fat wire type. Like the Date & Time, it would be a quantity of millisecond ticks, but a signed 64 bit integer instead of unsigned, and not relative to an epoch. The Splitter and Combiner should handle this in a similar manner to the Date & Time, except that no units larger than days should be used. The Signed Time Span could combine with other wire types as inputs to the Calculator to perform the following operations:
- Signed Time Span + Signed Time Span -> Signed Time Span
- Signed Time Span - Signed Time Span -> Signed Time Span
- Signed Time Span * Number -> Signed Time Span
- Signed Time Span / Number -> Signed Time Span
- Signed Time Span / Signed Time Span -> Number
- Signed Time Span % Signed Time Span -> Signed Time Span
- Date & Time + Signed Time Span -> Date & Time
- Date & Time - Signed Time Span -> Date & Time
- Date & Time - Date & Time -> Signed Time Span
-
Hrm, interesting idea... You can sort of do this already though right? Like, if you convert the date into a normal number, you can subtract and add and such as you would normally. And if you subtract a higher number (from a later date) from a lower number (an earlier date), you'll get a negative number which is how many ms is the difference.
What features would you want to have on top of that, specifically?
Please sign in to leave a comment.