Thomas Klausner > App-TimeTracker > App::TimeTracker::Task

Download:
App-TimeTracker-0.21.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View Bugs
Report a bug
Source  

NAME ^

App::TimeTracker::Task - interface to one task

SYNOPSIS ^

    my $task = App::TimeTracker::Task->new({
        start   => '1232010055',
        project => 'TimeTracker',
        tags    => \@tags,
        basedir =>'/path/to/basedir',
    });
    $task->stop_it;
    $task->write(  );  


    my $task = App::TimeTracker::Task->read('/path/to/file');
    say $task->start;       # epoche
    say $task->is_active;   # 1 or 0
    say $task->duration;    # in seconds

METHODS ^

new

    my $task = App::TimeTracker::App->new( $data );

Initiate a new task object.

stop_it

    $self->stop_it;
    $self->stop_it( $dt );

Stop this task, either at the specified $epoche, or now(). Throws an exception if the task is already stopped.

Returns $self for method chaining.

read

    my $task = App::TimeTracker::Task->read( $path );

Reads the specified file, parses it, generates a new object and returns the object.

write

   $task->write;
   $task->write( $basedir );

Serialises the data and writes it to disk.

If you got the object via read, you don't need to specifiy the $basedir. If this is the first time you want to write the object, the $basedir is neccesary.

set_current

    $task->set_current;

Makes $task the current task

get_current

    my $current = App::TimeTracker::Task->get_current( $basedir );

Loads the current task (i.e. the one you're working on ATM). Returns undef if there is no current task.

remove_current

    $self->remove_current;

Removes the current task file (because it's no longer current, but done).

remove_suspended

remove the suspendend file. NOT IMPLEMENTED YET

stop_current

Stops the current task

get_printable_interval

    my $string = $self->get_printable_interval([$start, stop]);

Returns a string like "worked 30 minutes, 23 seconds on Task (foo bar)"

beautify_duration

    my $nice_message = $self->beautify_duration($duration);

Turns an DateTime::Duration object into a nicer representation ("4 minutes, 31 seconds")

beautify_seconds

    my $nice_message = $self->beautify_seconds($seconds);

Turns an amount of seconds into a nicer representation ("4 minutes, 31 seconds")

nice_tags

    say $task->nice_tags;

Pretty-print the tag list

is_active

Returns true if the task is active, undef if it isn't

AUTHOR ^

Thomas Klausner, <domm at cpan.org>

COPYRIGHT & LICENSE ^

Copyright 2008, 2009 Thomas Klausner, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.