Skip to content

date search #549

Answered by JWCook
svshepherd asked this question in Q&A
Discussion options

You must be logged in to vote

The API almost has parameters to do what you want in a single query, but not quite. There is:

  • day: observed on this day of the month (any year; accepts multiple values)
  • month: observed on this month of the year (any year; accepts multiple values)

This will still have to be two separate queries when the start and end date are in different months, though. Here's an example that I think will do what you want.

Note that this doesn't account for larger date ranges that could span more than two months. It also doesn't handle leap years, or locations that span multiple time zones.

from calendar import monthrange
from datetime import datetime, timedelta
from pyinaturalist import enable_logging, g…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by svshepherd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants