| Summary: | Support timestamps as number system | ||
|---|---|---|---|
| Product: | [Applications] kcalc | Reporter: | Thomas Fischer <fischer> |
| Component: | general | Assignee: | Evan Teran <evan.teran> |
| Status: | REPORTED --- | ||
| Severity: | wishlist | CC: | andreas |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
In addition to decimal, octal, or binary number systems, kcalc should support timestamps as number systems. For example, if the user enters "0:30.5" this should be interpreted as 30 seconds and 500 milliseconds. Adding another number like "0:42" should be possible, resulting in the output of "1:12.5". It should be possible to do multiplications and divisions of timestamps with "regular" numbers. For example, "1:20" divided by 5 should give "0:16". For internal purposes, user-entered timestamp strings can be converted to a floating-point number. For example, the following regular expression can be used to make sense of the user's input: (?:(?:(?P<hour>\d+):)?(?P<minute>\d{1,2}):)?(?P<second>\d{1,2})(?P<fraction>[,.]\d+)? Expressed in Python, the floating-point representation gets computed as follows: hour = int(m.group("hour")) if m.group("hour") else 0 minute = int(m.group("minute")) if m.group("minute") else 0 second = int(m.group("second")) if m.group("second") else 0 fraction = float("0" + m.group("fraction").replace(",", ".")) if m.group("fraction") else 0.0 result = (hour * 60 + minute) * 60 + second + fraction