timetrap_formatters icon indicating copy to clipboard operation
timetrap_formatters copied to clipboard

Fix day formatter to respect date range filters

Open Copilot opened this issue 4 months ago • 0 comments

The day formatter was hardcoded to Date.today, ignoring entries from date ranges specified via -s/-e flags. Running t d -s 2013-07-29 -e 2013-07-29 -f day would show 0% and 0:00:00 even when entries existed for that date.

Changes

  • Determine target date from entries: Added determine_target_date method that extracts the latest date from filtered entries instead of using hardcoded Date.today
  • Refactored date checking: Renamed is_today to is_target_date to check against the dynamically determined target date
  • Preserved backward compatibility: Falls back to Date.today when entries array is empty
def determine_target_date
  if @entries.empty?
    Date.today
  else
    @entries.map { |e| Date.parse(e[:start].strftime(DATE_FORMAT)) }.max || Date.today
  end
end

def is_target_date(start_time, end_time, target_date)
  (Date.parse(start_time.strftime(DATE_FORMAT))..Date.parse(end_time.strftime(DATE_FORMAT))) === target_date
end

The formatter now correctly processes entries from any date range passed through timetrap's existing filter mechanism.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://index.rubygems.org:80/api/v1/dependencies
    • Triggering command: /usr/bin/ruby3.2 /home/REDACTED/.local/share/gem/ruby/3.2.0/bin/bundle install (http block)
  • http://index.rubygems.org:80/versions
    • Triggering command: /usr/bin/ruby3.2 /home/REDACTED/.local/share/gem/ruby/3.2.0/bin/bundle install (http block)
  • http://rubygems.org:80/specs.4.8.gz
    • Triggering command: /usr/bin/ruby3.2 /home/REDACTED/.local/share/gem/ruby/3.2.0/bin/bundle install (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Issue Title: day formatter: Output from previous days Issue Description: Open

@jostber

Description

jostber

opened on Jul 30, 2013

Contributor

When I run a command with the day formatter to get output for days before today it does not work:

$ t d -s 2013-07-29 -e 2013-07-29 -f day [ ] 0% 0:00:00

Activity

samg

samg commented on Aug 7, 2013

samg

on Aug 7, 2013

Owner

Maybe @dorzey or @duckpuppy would be willing to take a look and extend the formatter to handle start and end dates. They've both worked on its previously.

If you are able to extend it to handle that case feel free to send a pull request back to this repo.

Thanks!

duckpuppy

duckpuppy commented on Aug 13, 2013

duckpuppy

on Aug 13, 2013

Contributor

I'll make some time to look at this - may be a few more days before I have some real time to work on it. Fixes https://linear.app/sgrock/issue/SGR-7/day-formatter-output-from-previous-days

Comment by User 6d6b0ab0-3e10-41bc-a363-65cca3b8e154: Sorry repo is samg/timetrap_formatters

Comment by User 88eb2cfd-1be5-4fda-a107-dd28b713d02e: 📋 I wasn't able to determine which GitHub repository to work in.

Please tell me which repository this work should be done in using the format owner/repository-name (e.g., github/copilot), then I'll automatically start working on it!

Comment by User 6d6b0ab0-3e10-41bc-a363-65cca3b8e154: @githubcopilot can you make this improvement to sam/timetrap_formatters


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Oct 28 '25 20:10 Copilot