https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=288406

            Bug ID: 288406
           Summary: calendar(1) with -A 0 wrongly getting set to 1 in some
                    conditions
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: [email protected]
          Reporter: [email protected]

Normally, using calendar(1) with `-A 0` should give only today's calendar
reminders, not the next day's.  However, in certain conditions, it seems to get
overridden:

    $ date +"%a %Y-%m-%d"
    Wed 2025-07-23
    $ calendar -A 0 -f /usr/share/calendar/calendar.freebsd  | cut -f1 | uniq
    Jul 23 
    Jul 24

This appears to be caused by day.c:settimes() which correctly receives an
`after` value of 0, but then overrides that in the first `if` clause, setting
it to 1:

    /* Friday displays Monday's events */
    if (after == 0 && before == 0 && friday != -1)
        after = tp.tm_wday == friday ? 3 : 1;

inserting debug probes before/after this statement, the `after` value gets set
to 1 instead of the 0 from the command-line.  I'm not sure how that logic is
*supposed* to work, but I'm almost certain it's wrong.  Either it should be `:
0` not `: 1`. or the check should be `after == 1` (my vote for most-likely) or
`after > 0` instead of `after == 0`.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to