3 ms·
been hand-rolling date -d plus a wrapper script for newsletter scheduling for years. Stuff like "next second Tuesday after a holiday" and "convert these timesta
by onceonceonce 4mo ago
been hand-rolling date -d plus a wrapper script for newsletter scheduling for years. Stuff like "next second Tuesday after a holiday" and "convert these timestamps to a reader's local time before send". biff time seq monthly -w 2-tue would have replaced about 40 lines of bash for me.
- burntsushi 4mo agoYes!!! To spell it out (with the new biff -> bttf name): $ bttf time seq monthly -w 2-tue -u 1y | bttf time fmt -f '%c' Tue, Jun 9, 2026, 11:15:11 AM EDT Tue, Jul 14, 2026, 11:15:11 AM EDT Tue, Aug 11, 2026, 11:15:11 AM EDT Tue, Sep 8, 2026, 11:15:11 AM EDT Tue, Oct 13, 2026, 11:15:11 AM EDT Tue, Nov 10, 2026, 11:15:11 AM EST Tue, Dec 8, 2026, 11:15:11 AM EST Tue, Jan 12, 2027, 11:15:11 AM EST Tue, Feb 9, 2027, 11:15:11 AM EST Tue, Mar 9, 2027, 11:15:11 AM EST Tue, Apr 13, 2027, 11:15:11 AM EDT Tue, May 11, 2027, 11:15:11 AM EDT More examples here: https://github.com/BurntSushi/biff/blob/master/GUIDE.md#datetime-sequences https://github.com/BurntSushi/biff/blob/master/GUIDE.md#date... Implementing the RFC 5545 recurrence rules was quite a lot of fun: https://github.com/BurntSushi/biff/blob/4c75d5cf6e09310e74ca74ad3abde48a73b648ab/src/ical.rs https://github.com/BurntSushi/biff/blob/4c75d5cf6e09310e74ca... I'm quite proud of it, because if you look at the implementation, it's almost entirely about dealing with the specification rules. All of the datetime bullshit (including handling time zones) is all deferred to Jiff. Plus, the tests are nearly 4,000 lines. While the implementation is 2,000 lines.
- jayknight 4mo agoI implemented those recursion rules (probably very poorly) years ago. I still often think about the ways I did and probably should have handled those. It was an interesting problem.