Timewarrior Documentation

repository·develop·Indexed 23 days ago

https://github.com/gothenburgbitfactory/timewarrior

A portable, open-source time tracking utility supporting simple stopwatch features, complex calendar-based backfilling, and flexible reporting. Includes documentation on building from source, managing holiday files, using the timew-chart visualizer, and command-line operations such as timew annotate, timew cancel, and timew config.

Tokens
25.1K
Snippets
51
Records
165
Agent score
78%

What's inside Timewarrior

  1. Understand Timewarrior command line syntax and elements

    develop

    Timewarrior uses a command-line interface where the first word is the command, followed by optional args. Commands can also use subcommands to specify specific behaviors.

    Key Syntax Elements

    • Words: The basic elements separated by whitespace (or quotes).
    • Subcommands: Used to refine command behavior (e.g., timew tag list).
    • Dates: Points in time like 1pm, 10:33, 2017-04-11T17:12:23, or now.
    • Durations: Time spans like one day, two weeks, today, or yesterday.
    • Ranges: Time intervals defined by two dates (e.g., 09:45 - 11:15) or a date and a duration (e.g., two hours before 10:45).
    • Tags: Lexical tokens used to label intervals.
    • Filters: Used to limit operations to specific tags or ranges.
    • Hints: Words starting with : (e.g., :quiet) that request modified behavior. Hints are optional and commands may ignore them if they are not relevant to the context.
  2. Use hints to fill gaps or resolve overlaps in timew modify

    develop

    The timew modify command supports two specific hints to handle interval boundaries and collisions:

    • :fill: Automatically adjusts the interval to close gaps with adjacent intervals.
      • When using start, it fills the gap between the interval and the previous interval.
      • When using end, it fills the gap between the interval and the next interval.
      • When using range, it fills gaps on both sides.
    • :adjust: Forces the modification even if the new range overlaps with an existing interval. This will overwrite the overlapping interval.
  3. Configure Timewarrior settings

    develop

    Timewarrior configuration is stored in timewarrior.cfg. On Unix systems, it defaults to ~/.config/timewarrior/timewarrior.cfg (following XDG Base Directory specs) unless ~/.timewarrior exists. On non-Unix systems, it is located at ~/.timewarrior/timewarrior.cfg.

    You can also override the data location using the TIMEWARRIORDB environment variable.

  4. Specify date and time intervals in Timewarrior

    develop

    Timewarrior uses flexible syntax to define intervals (blocks of time). An interval can be 'closed' (having both a start and an end date) or 'open' (having only a start date).

    You can specify intervals using the following patterns:

    • [from] <date>: An open interval starting at a specific time.
    • [from] <date> to/- <date>: A closed interval between two points.
    • [from] <date> for <duration>: An open interval starting at a time and lasting for a specific duration.
    • <duration> before/after <date>: A closed interval relative to a specific time.
    • <duration> ago: A closed interval relative to the current time.
    • [for] <duration>: An open interval representing a duration (often used relative to now).

    Note: <duration> refers to time lengths like 2h (2 hours).

    from 9:00
    from 9am - 11am
    from 9:00:00 to 11:00
    from 9:00 for 2h
    2h after 9am
    2h before 11:00
    2h ago
    for 2h
  5. Understand the Timewarrior DOM structure

    develop

    The Timewarrior DOM (Document Object Model) provides a hierarchical way to access data from the Timewarrior database. All DOM references must start with the dom prefix. The structure is divided into four primary sub-references:

    1. dom.tracked: Accesses all intervals returned by a database query. This reference supports filtering by range and tags.
    2. dom.active: Accesses the currently active time tracking interval. This is invalid if no time is being tracked.
    3. dom.tags: Accesses all tags present in the database.
    4. dom.rc: Accesses Timewarrior configuration settings.
  6. Handle range boundaries with named dates

    develop

    Because named dates (like today, yesterday, etc.) are defined with the time 0:00:00, using them as the upper bound of a range will exclude the day they represent.

    If you want to include the current day in a relative sum, use now or tomorrow instead of today.

    Example: Summing the last 2 days

    To exclude the current day:

    $ timew sum 2d before today

    To include the current day:

    $ timew sum 2d before now
    $ timew sum 2d before tomorrow
    $ timew sum 2d before today
    $ timew sum 2d before now
    $ timew sum 2d before tomorrow
  7. Start, stop, or cancel time tracking

    develop

    Use basic commands to manage active time intervals.

    • start: Creates a new open interval. If an interval is already active, it closes the current one and starts a new one only if the provided tags differ from the current ones.
    • stop: Closes the current open interval at the specified date. If tags are provided, it creates a new open interval containing only the tags from the current interval that were not in the provided list.
    • cancel: Deletes the current open interval entirely.
    timew start
    timew stop 17:00
    timew cancel
  8. Use the timew-chart report to visualize time

    develop

    The timew-chart command displays a visual summary of tracked and untracked time using colored blocks on a timeline. It provides three distinct views based on the time granularity requested: day, week, and month.

    Available Commands

    • timew day: Shows a chart for a single day (defaults to today).
    • timew week: Shows a chart for a single week (defaults to the current week).
    • timew month: Shows a chart for a single month (defaults to the current month).

    Filtering and Selection

    You can filter the chart output using:

    • Date Ranges: Specify a range (e.g., 1st - today).
    • Tags: Filter by one or more tags (e.g., FOO BAR).
    • IDs: Filter by specific interval IDs (e.g., @3 @4).

    Chart Hints

    Use these hints to modify the visual output:

    • :blank: Displays only excluded (untracked) time, hiding all tracked time blocks. Useful for visualizing gaps.
    • :ids: Displays the unique IDs alongside the time intervals.
    timew month 1st - today
    timew week FOO BAR
    timew day @3 @4