+sub start_project ($$)
+{
+ my $start_time = shift;
+ my $title = shift;
+
+
+ my $current = get_current_project();
+ if ( not $current )
+ {
+ if ( not $title )
+ {
+ $current = get_last( );
+ }
+ else
+ {
+ $current = get_project_id( $title );
+ if ( not $current )
+ {
+ printf("No project by that name! Creating a new one.\n");
+ $current = create_project($title);
+ }
+ }
+
+ # Break off here if we haven't gotten an ID yet.
+ return undef if not $current;
+
+ set_current_project($current);
+
+ # First iteration is VERY naive: simply add the start time to the bottom of the tracking file
+ # Will have to do more logic: if the start point is before one of the times already in the track,
+ # the file will have to be manipulated to get coherent tracking!
+ open (TRACK, ">>" . $trk_dir . "/" . $current . "/tracking" ) or die ("Unable to open file, $!");
+ printf(TRACK "[%s]", time2str($start_time));
+ close (TRACK);
+
+ return $current;
+ }
+
+ return undef;
+}
+
+sub close_project ($)
+{
+
+ my $stop_time = shift;
+
+ my $current = get_current_project();
+
+ die ("Project exists, but tracking file does not!") if ( not -f $trk_dir . "/" . $current . "/tracking" );
+
+ # First iteration is VERY naive: simply add the stop time to the bottom line of the tracking file
+ # Will have to do more logic: if the start point is before one of the times already in the track,
+ # the file will have to be manipulated to get coherent tracking!
+ # In addtion to this: actually do some file sanity checking!
+ open (TRACK, ">>" . $trk_dir . "/" . $current . "/tracking" ) or die ("Unable to open file, $!");
+ printf(TRACK " to [%s]\n", time2str($stop_time));
+ close (TRACK);
+
+ unlink ( $trk_dir . "/current" );
+}
+