parnoldx / timer

The ultimate tea timer
GNU General Public License v3.0
16 stars 6 forks source link

Add float parsing #4

Closed erikbrinkman closed 6 years ago

erikbrinkman commented 6 years ago

This PR consists of two important changes

  1. I updated the long regex to parse the string once and find all day/minutes/hours/seconds, and enforced a strict match, i.e. currently gibberish 5 gets interpreted as 5 minutes, but this seems like undesired behavior.
  2. It parses the fields as doubles and sets the TimeSpan accordingly, so 3.5 is now interpreted "correctly" as 3 minutes 30 seconds instead of 5 seconds (the 3. is ignored as an unmatched prefix).
parnoldx commented 6 years ago

Thank you for the contribution. There is a small problem with this branch. When I enter 2 then the timer is started with 3 minutes. This is caused through the TimeSpan.from_glib constructor. There a minute is added and since you now also call it in in the parsing step 2 minutes are added. The adding is needed in the TimeObject.update method otherwise the timer e.g. finishes at 1 minute and so on.

Can you also allow "," as decimal seperator.

erikbrinkman commented 6 years ago

Thanks for the catch. I'm not sure how I missed it. That's what I get for not really looking at from_glib. These should both be fixed.

parnoldx commented 6 years ago

Thank you. Works great.