Skip to content

Introduce second-precision feature to Bartib #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 16, 2025

Conversation

johnDeSilencio
Copy link
Contributor

What?

This PR introduces a second-precision feature to Bartib that allows users who compile the binary from source to record timestamps in their log file and perform report calculations with a precision of seconds instead of a precision of minutes, as is the default.

Why?

I use Bartib in my post-checkout git hook so I can capture the amount of time I spend on each branch over the course of the day. Sometimes, I have to flip between branches quickly. I see a lot of the following timestamps in my log file:

2025-06-12 23:24 - 2025-06-12 23:24 | // ...
// ...
2025-06-12 23:28 - 2025-06-12 23:28 | // ...
2025-06-12 23:28 - 2025-06-12 23:28 | // ...
// ...

Those logs entries effectively become "lost" minutes, if I am not mistaken. That might not seem like much, but over a period of several months using Bartib, that can amount to potentially hours worth of "lost" minutes.

How?

I didn't want to alter the default timestamp precision for all users, so I put these changes behind the feature gate second-precision and preserved all of the old code.

Breaking changes?

The only thing that might be considered a breaking change is the changes I made to data::parse_timepart(). I added some additional logic to detect if there is a precision mismatch. For example, in the following screenshot, bartib was compiled without the second-precision flag but has encountered a log with timestamps that have second precision:

image

`bartib_log.txt`
2025-06-12 23:23:12 - 2025-06-12 23:23:28 | my project | my description
2025-06-12 23:24:01 - 2025-06-12 23:24:20 | my project | my description
2025-06-12 23:24:38 - 2025-06-12 23:24:59 | my project | my description
2025-06-12 23:25:44 - 2025-06-12 23:25:54 | my project | my description
2025-06-12 23:28:00 - 2025-06-12 23:28:14 | my project | my description
2025-06-12 23:39:17 - 2025-06-12 23:39:25 | my project | my description
2025-06-12 23:39:25 | another project | another description

I want to thank you for all of the hard work you put into this crate! This has got to be one of the best organized crates I've seen yet. I was able to make these changes in less than two hours on a single weekend - and everything worked on the first try. I know no higher honor I can given an open source maintainer than that.

Let me know if there are any changes that you'd like me to make! I'm open to feedback :)

Cheers,

  • Nick

@johnDeSilencio
Copy link
Contributor Author

I have to head to bed now, but I'll be back on tomorrow to post functional test results!

@nikolassv
Copy link
Owner

Thank you for your work! This is something I would have never thought of but I can understand the usecase. I hope I will be able soon to have a look at your changes and merge them.

This reverts commit cc5327a.
@johnDeSilencio
Copy link
Contributor Author

Not sure how thorough of testing you're looking for, but here's a short clip of me using Bartib with second precision in the timestamps:

compressed_bartib.mp4

Let me know if there's any other functionality you want me to test :)

@nikolassv nikolassv merged commit da60422 into nikolassv:master Jun 16, 2025
@nikolassv
Copy link
Owner

Thanks, this looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants