Skip to main content

time tracker and reporter

Project description

https://travis-ci.org/diefans/zeitig.svg?branch=master PyPI - Python Version PyPI

A time tracker.

The basic idea is to store all situation changes as a stream of events and create a report as an aggregation out of these.

Usage

Usage: z [OPTIONS] [GROUP] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  add     Apply tags and notes.
  break   Change to or start the `break` situation.
  remove  Remove tags and flush notes.
  report  Create a report of your events.
  work    Change to or start the `work` situation.

Example session

You may add a timestamp, as in the example, which is parsed for your timezone. You may abbreviate the commands, so the shortes way to track your time of a running project is just z w and z b.

> export ZEITIG_STORE=/tmp/zeitig; mkdir $ZEITIG_STORE

> z foobar work -t foo "2018-04-01 08:00:00"

> z break "2018-04-01 12:00:00"

> z w "2018-04-01 13:00:00"

> z b "2018-04-01 17:30:00"

> z
Actual time: 2018-05-04 23:09:01

Actual group: foobar of foobar
Last situation in foobar: Break started at 2018-04-01 17:30:00 since 797.65 hours

Store used: /tmp/zeitig/olli
Last event: groups/foobar/source/2018-04-01T15:30:00+00:00

> z report
Working times for foobar until Friday 04 May 2018

Week: 13
        2018-04-01 08:00:00 - 12:00:00 - 4.00 - foo
        2018-04-01 13:00:00 - 17:30:00 - 4.50

Total hours: 8.50

Internals

You may create a .zeitig directory somewhere in your current working directory path to use it as the store. Other defaults are ~/.config/zeitig and ~/.local/share/zeitig.

For every user is a separate directory created, which containes the groups and the events sources:

.zeitig/
    |
    +- <user>
        |
        +- last ---------------+
        |                      |
        +- groups              |
        |   |                  |
        |   +- <group>         |
        |       |              |
        |       +- source      |
        |       |   |          v
        |       |   +- <event UTC timestamp>
        |       |
        |       +- templates
        |       |   |
        |       |   +- <jinja template>
        |       |
        |       +- template_defaults.toml
        |       |
        |       +- template_syntax.toml
        |
        +- templates
        |   |
        |   +- <jinja template>
        |
        +- template_defaults.toml
        |
        +- template_syntax.toml

The events are stored as simple toml files.

Reports

Events are fully exposed to the reporting template. You can pipeline certain filters and aggregators to modifiy the event stream.

Templates are rendered by jinja2. You can modify the start and end tags by a special template_syntax.toml file.

An example latex template may look like this:

\documentclass{article}

\usepackage[a4paper, total={6in, 8in}]{geometry}

\usepackage{longtable,array,titling,booktabs}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\title{\vspace{-13em}Timesheet\vspace{0em}}
\author{\vspace{-10em}}
\date{\vspace{-5em}}

% sans serif font
\renewcommand{\familydefault}{\sfdefault}

\begin{document}
\maketitle
\thispagestyle{empty} % no page footer
\vspace{-5em}
\begin{longtable}{
    >{\raggedleft\arraybackslash}r
    >{\raggedright\arraybackslash}l}
    \textbf{Client}: & We do something special\\
    \textbf{Contractor}: & Oliver Berger\\
    \textbf{Project number}: & 12-345-6789-0\\
\end{longtable}

\begin{longtable}{
>{\raggedright\arraybackslash}l
>{\raggedright\arraybackslash}l
>{\raggedleft\arraybackslash}r
>{\raggedright\arraybackslash}l}
    Start & End & Hours & Description\\
\BLOCK{for event in events.pipeline(
    report.source,
    events.filter_no_breaks,
    events.Summary.aggregate,
    events.DatetimeChange.aggregate
    )-}
    \BLOCK{if py.isinstance(event, events.DatetimeChange) and event.is_new_week}
    \midrule
\BLOCK{endif-}
    \BLOCK{if py.isinstance(event, events.Work)}
    \VAR{event.local_start.to_datetime_string()} & \VAR{event.local_end.to_time_string()} & \VAR{'{0:.2f}'.format(event.period.total_hours())} & \BLOCK{if event.tags}\VAR{', '.join(event.tags)}\BLOCK{endif-}\\
\BLOCK{endif-}

    \BLOCK{if py.isinstance(event, events.Summary)}
    \midrule
    \multicolumn{2}{l}{\textbf{Total hours}} & \textbf{\VAR{'{0:.2f}'.format(event.works.total_hours())}} & \\
\BLOCK{endif-}
\BLOCK{-endfor-}
\end{longtable}
\vspace{5em}
\begin{longtable}{
>{\centering\arraybackslash}p{3.5cm}
l
>{\centering\arraybackslash}p{5.5cm}}
\cline{1-1}
\cline{3-3}
    Date & & Signature of client\\
\end{longtable}

\end{document}

Jinja syntax

Group jinja template syntax will be merged into user syntax:

[jinja_env]

[jinja_env.latex]
# define a latex jinja env
block_start_string = "\\BLOCK{"
block_end_string = "}"
variable_start_string = "\\VAR{"
variable_end_string = "}"
comment_start_string = "\\#{"
comment_end_string = "}"
line_statement_prefix = "%%"
line_comment_prefix = "%#"
trim_blocks = true
autoescape = false

[templates]
# map a template name to a jinja env
latex_template = "latex"

Jinja defaults

You may define also template defaults for a group, which will be merged into the user template defaults.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zeitig-0.3.3.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

zeitig-0.3.3-py3-none-any.whl (66.5 kB view details)

Uploaded Python 3

File details

Details for the file zeitig-0.3.3.tar.gz.

File metadata

  • Download URL: zeitig-0.3.3.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2

File hashes

Hashes for zeitig-0.3.3.tar.gz
Algorithm Hash digest
SHA256 b4d73ddcdb66bc5eb63e882794761f85f6bb79408b566929d9f6ac05bc3544a4
MD5 8c193cc9113b26defabd6bb24905bbef
BLAKE2b-256 d55f400b8e9284fcec61af962183c9c7dfe620fa1ac8ca543053cdac33ed0756

See more details on using hashes here.

File details

Details for the file zeitig-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: zeitig-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 66.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.2

File hashes

Hashes for zeitig-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a40f20f033b942ba33123889a6bc9c8259e01d46e12dda509919d954831d27dc
MD5 b4a5951b6d8ff6a9ce7ddb28bc98fe45
BLAKE2b-256 17ea6f3477c503897ce40a2d8a356b46033e645ed33f13890baccee4c96a2322

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page