ali-rantakari / icalBuddy

Command-line utility for printing events and tasks from the OS X calendar database.
149 stars 33 forks source link

iCalBuddy omits results which are in range #34

Open porg opened 3 years ago

porg commented 3 years ago

Reproduction

Version: iCalBuddy 1.10.1 on macOS 11.2.1

Expected

Actual

How I realized the bug

➜  ~ icalBuddy -ic "MyCal" eventsFrom:2019 to:2020 | egrep "^• " | wc -l
      35
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2000 to:2030 | egrep "^• " | wc -l
       0 # How can that be? Maybe because it includes "too much future"?
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2000 to:2020 | egrep "^• " | wc -l
       0 # Another try. No more future. Still zero. Strange…
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2010 to:2020 | egrep "^• " | wc -l
      16 # Another try: Less past. Ok more.
         # But still less than the 35 results for just 2019-2020 
         # which is just a subset of 2010-2020! Very strange!
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2012 to:2020 | egrep "^• " | wc -l
       9 # Ok seems plausible to get less if I narrow the range. (Ignoring the overall flaw ofc)
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2011 to:2020 | egrep "^• " | wc -l
      16 # Let's now step by step go further back into the past with "eventsFrom".
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2010 to:2020 | egrep "^• " | wc -l
      16
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2009 to:2020 | egrep "^• " | wc -l
      30 # Here it reaches it's maximum.
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2008 to:2020 | egrep "^• " | wc -l
      21 # And then it gets less, although I keep widening the range.
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2007 to:2020 | egrep "^• " | wc -l
      14 # Turns out the first event in this calendar was from 2009.
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2006 to:2020 | egrep "^• " | wc -l
      14 # The flawed logic seems to be: The more "emptiness your query range contains, the fewer results.
➜  ~ icalBuddy -ic "MyCal" eventsFrom:2005 to:2020 | egrep "^• " | wc -l
       0 # Until being totally zero.

Turns out to be reproducible with sample calendar

Again: Fewer results for larger ranges, simply not comprehensible.

➜  ~ icalBuddy -ic "Test-iCalBuddy" eventsFrom:2010 to:2011
• Test 2011-04-05 (Test-iCalBuddy)
    05.04.2011 at 10:00 - 11:00
    # 3 events actually in sample calendar, but iCalBuddy lists only 1.
➜  ~ icalBuddy -ic "Test-iCalBuddy" eventsFrom:2010 to:2012
• Test 2011-04-05 (Test-iCalBuddy)
    05.04.2011 at 10:00 - 11:00
   # Extending range. Should yield 3, still only yields 1.
➜  ~ icalBuddy -ic "Test-iCalBuddy" eventsFrom:2010-01-01 to:2012-12-31 # More explicit syntax
• Test 2010-01-06 (Test-iCalBuddy)
    06.01.2010 at 10:00 - 11:00
• Test 2010-03-03 (Test-iCalBuddy)
    03.03.2010 at 11:00 - 12:00
• Test 2011-04-05 (Test-iCalBuddy)
    05.04.2011 at 10:00 - 11:00
   # More explicit syntax, more results. This one is correct for once.
➜  ~ icalBuddy -ic "Test-iCalBuddy" eventsFrom:2010-01-01 to:2020-12-31
• Test 2010-01-06 (Test-iCalBuddy)
    06.01.2010 at 10:00 - 11:00
• Test 2010-03-03 (Test-iCalBuddy)
    03.03.2010 at 11:00 - 12:00
• Test 2011-04-05 (Test-iCalBuddy)
    05.04.2011 at 10:00 - 11:00
• Test 2013-04-09 (Test-iCalBuddy)
    09.04.2013 at 10:00 - 11:00
   # Extended range. Should yield 6 (even with roughest rounding), still only yields 4.
    # Results from 2017 and 2018 are omitted, although in range.
porg commented 3 years ago

Until iCalBuddy works correctly in that regard, you may use this AppleScript workaround: osascript -e 'tell application "Calendar" to count events of calendar "myCal"'

Returned plausible results under macOS 11.2.1 Big Sur.