ANOTHER BUG FIX! (much thanks to "ParisWiki" for reporting it)

in showtable(), a calculation error was caused by these lines:

<$vars
   elapsed_min={{{ [{!!elapsed}divide[60]trunc[]] }}}
   elapsed_minsec={{{ [<elapsed_min>multiply[60]] }}}
   elapsed_sec={{{ 
[{!!elapsed}subtract<elapsed_minsec>multiply[1000]trunc[]divide[1000]] 
}}}>
<$vars
   total_min={{{ [{!!total}divide[60]trunc[]] }}}
   total_minsec={{{ [<total_min>multiply[60]] }}}
   total_sec={{{ 
[{!!total}subtract<total_minsec>multiply[1000]trunc[]divide[1000]] 
}}}>

The problem is that the "minsec" calculation depends on the value of "min", 
and the "sec" calculation depends on the value of "minsec".  The issue is 
that I was using one $vars widget to calculate all three of the values, but 
because of the dependencies, I needed to calculate them one at a time, so 
that each calculation can correctly reference the results of the previous 
one.

The bug only appeared when the started/stopped values were at least 1 
minute apart.  The reported minutes were correct, but the reported seconds 
included the full minutes (expressed as seconds).

For example: 
1287 seconds was reported as "21 minutes 1287 seconds".  However, 21 
minutes is 1260 seconds, so it should have shown "21 minutes, 27 seconds"
and
1459 seconds was reported as "24 minutes 1459 seconds".  However, 24 
minutes is 1440 seconds, so it should have shown "21 minutes, 19 seconds"

The fixed code is:
<$vars elapsed_min={{{ [{!!elapsed}divide[60]trunc[]] }}}>
<$vars elapsed_minsec={{{ [<elapsed_min>multiply[60]] }}}>
<$vars elapsed_sec={{{ 
[{!!elapsed}subtract<elapsed_minsec>multiply[1000]trunc[]divide[1000]] 
}}}>
<$vars total_min={{{ [{!!total}divide[60]trunc[]] }}}>
<$vars total_minsec={{{ [<total_min>multiply[60]] }}}>
<$vars total_sec={{{ 
[{!!total}subtract<total_minsec>multiply[1000]trunc[]divide[1000]] 
}}}>

I've posted the revised code to
   http://TiddlyTools.com/timer.html

To import the update into your own TiddlyWiki, just drag the "TaskTimer" 
title from the sidebar listing, and drop it on your open TiddlyWiki.

enjoy,
-e

>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/976f9f29-c911-4a2a-8d4b-154a68a6ae27o%40googlegroups.com.

Reply via email to