Razeeman / Android-SimpleTimeTracker

Simple app that tracks time.
GNU General Public License v3.0
536 stars 68 forks source link

[BUG]: time is off by 1 minute in some occasions #174

Open precla opened 3 months ago

precla commented 3 months ago

see attached screenshot, should be 7:46.

edit: Seems to me that it considers seconds when calculating the total time.

Screenshot_20240325-083406_Simple_Time_Tracker

cogk commented 3 months ago

Not a bug: the time period 08:29:59 - 16:15:00 is 7h 45m 1s long


edit: Seems to me that it considers seconds when calculating the total time.

edit: yes

precla commented 3 months ago

would it make sense to add the option to ignore seconds?

Razeeman commented 2 months ago

Hello! Ignoring seconds seems like an easy solution, but I'm on the fence about it because it would probably require some complex logic especially in statistics to recalculate all records without seconds every time statistics is updated. Hope this make sense. At the moment I've added a different representation for the records like this, showing that is a rounded time (shown in attached screenshot). This record is actually 59m 1s long, but shown as 1h if seconds are disabled.

image
cogk commented 2 months ago

Maybe it would be possible to round all timestamps before inserting them in the database (= truly ignoring seconds)?

Razeeman commented 2 months ago

This is also an option, but it would not fix previously created records. Ideally best way would be to store seconds but just ignore them on the ui. But I'm not sure how to do it, maybe it would require too much work and your solution would be implemented in the end :)

cogk commented 2 months ago

Or maybe It's possible to do rounding when reading the DB instead. So basically rounding on the database access layer. Values are stored faithfully, but "cleaned-up" on read.

Pros: it's easy because there is only one place to update in the code (database reading).
Cons: it's kind of a hack 😄


The main problem with doing it on the UI side of things, is that there are a lot of changes to do, potentially forgetting locations.

precla commented 2 months ago

how about when "Now" is pressed while manually adding an entry (and every where else) - keep seconds. If user sets hh:mm, then set seconds to 00? Would not require any re calculation of old entries, nor a complex logic. And old entries with seconds: it is what it is :)

Razeeman commented 2 months ago

@cogk Wow, didn't think about rounding on database read. Seems like an interesting idea, will look into it!