https://bugs.kde.org/show_bug.cgi?id=460684

            Bug ID: 460684
           Summary: Support timestamps as number system
    Classification: Applications
           Product: kcalc
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: wishlist
          Priority: NOR
         Component: general
          Assignee: ete...@alum.rit.edu
          Reporter: fisc...@unix-ag.uni-kl.de
  Target Milestone: ---

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

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to