printf(" %s {projects|list} [verbose]\n", $0);
printf(" %s report [{terse|standard|verbose|details}] [<trackname>]\n", $0);
printf(" %s edit <trackname>\n", $0);
+ printf(" %s status\n", $0);
printf("\nSee README.txt for more information\n");
exit(-1);
return strftime("%Y-%m-%d %H:%M", localtime($t));
}
+sub delta2str ($)
+{
+ my $delta = shift;
+ my $t = $delta;
+ my $hours = $t / 3600;
+ $t = $delta % 3600;
+ my $minutes = $t / 60;
+ return sprintf("%d hours %d minutes", $hours, $minutes);
+}
+
sub parse_arguments ($)
{
if ( not $silent )
{
- my $t = $delta;
- my $hours = $t / 3600;
- $t = $delta % 3600;
- my $minutes = $t / 60;
- printf(" %s to %s => %d hours %d minutes\n", $start, $end, $hours, $minutes);
+ printf(" %s to %s => %s\n", $start, $end, delta2str($delta) );
}
$total += $delta;
}
+sub current_starttime (;$)
+{
+ my $trk_id = shift;
+ my $wrk_dir = $trk_dir;
+ $wrk_dir = $trk_dir . "/" . $trk_id if $trk_id;
+
+ my $line = undef;
+
+ my $current = get_current_id( $trk_id );
+ open (TRACK, "<" . $wrk_dir . "/" . $current . "/tracking" ) or die ("Unable to open file, $!");
+ while ( <TRACK> )
+ {
+ $line = $_;
+ }
+ close ( TRACK );
+ return 0 if not $line =~ m/\[(\d\d\d\d-\d\d-\d\d \d\d:\d\d)\]/;
+ return str2time($1);
+}
+
############################################################
if ( ! -d $trk_dir )
print("\n") if $output >= 1;
- my $t = $total;
- my $hours = $t / 3600;
- $t = $total % 3600;
- my $minutes = $t / 60;
+ printf("Total: %s\n", delta2str($total) );
- printf("Total: %d hours %d minutes\n", $hours, $minutes);
if ( $output >= 2 )
{
- my $t = $subtotals;
- my $hours = $t / 3600;
- $t = $subtotals % 3600;
- my $minutes = $t / 60;
- printf("Time logged on tasks: %d hours %d minutes\n", $hours, $minutes);
+ printf("Time logged on tasks: %s\n", delta2str($subtotals) );
}
print("# End of report\n") if $output >= 1;
}
+elsif ( $command eq "status" )
+{
+
+ my $trk_id = get_current_id();
+ if ( not $trk_id )
+ {
+ printf("Not currently tracking anything.\n");
+ $trk_id = get_last_id();
+ if ( $trk_id )
+ {
+ printf("Last track was: %s\n", get_track_name( $trk_id ) );
+ }
+ exit(1);
+ }
+ printf("Currently tracking: %s\n", get_track_name( $trk_id ) );
+ my $t = current_starttime();
+ printf("Tracking started at %s\n", scalar localtime $t);
+ printf("Time elapsed since start of session: %s\n", delta2str(time - $t) );
+ my $activity = get_current_id( $trk_id );
+ if ( $activity )
+ {
+ printf("\nCurrent sub-task/activity is: %s\n", get_track_name( $activity, $trk_id ) );
+ my $t = current_starttime($trk_id);
+ printf("Activity started at %s\n", scalar localtime $t);
+ printf("Time elapsed since start of activity: %s\n", delta2str(time - $t) );
+ }
+ else
+ {
+ $activity = get_last_id( $trk_id );
+ if ( $activity )
+ {
+ printf("\nLast track was: %s\n", get_track_name( $activity, $trk_id ) );
+ }
+ }
+}
elsif ( $command eq "edit" )
{