| 1 | --- |
| 2 | myst: |
| 3 | html_meta: |
| 4 | "description lang=en": | |
| 5 | API Reference of functions and classes. |
| 6 | --- |
| 7 | |
| 8 | |
| 9 | # API Reference |
| 10 | |
| 11 | This is the public API for this library. |
| 12 | |
| 13 | ## Core functionality |
| 14 | |
| 15 | This is the core of the functionality of the library. |
| 16 | |
| 17 | The first step is to customize which components to query with {py:func}`recurring_ical_events.of`. |
| 18 | |
| 19 | ```{eval-rst} |
| 20 | .. autofunction:: recurring_ical_events.of |
| 21 | ``` |
| 22 | |
| 23 | ## Query |
| 24 | |
| 25 | `of()` returns a {py:class}`recurring_ical_events.CalendarQuery` object, which can be used to query the calendar. |
| 26 | For the most common cases, you do not need to look any further. |
| 27 | |
| 28 | ```{eval-rst} |
| 29 | .. autoclass:: recurring_ical_events.CalendarQuery |
| 30 | :members: |
| 31 | :exclude-members: ComponentsWithName |
| 32 | ``` |
| 33 | |
| 34 | ### list from `at()` and `between()` |
| 35 | |
| 36 | The result of both {py:meth}`recurring_ical_events.CalendarQuery.between` and |
| 37 | {py:meth}`recurring_ical_events.CalendarQuery.at` is a list of {py:class}`icalendar.cal.Component` |
| 38 | objects like {py:class}`icalendar.cal.Event`. |
| 39 | By default, all attributes of the event with repetitions are copied, like ``UID`` and ``SUMMARY``. |
| 40 | However, these attributes may differ from the source event: |
| 41 | |
| 42 | * ``DTSTART`` which is the start of the event instance. (always present) |
| 43 | * ``DTEND`` which is the end of the event instance. (always present) |
| 44 | * ``RDATE``, ``EXDATE``, ``RRULE`` are the rules to create event repetitions. |
| 45 | They are **not** included in repeated events, see [Issue 23]. |
| 46 | To change this, use ``of(calendar, keep_recurrence_attributes=True)``. |
| 47 | |
| 48 | [Issue 23]: https://github.com/niccokunzmann/python-recurring-ical-events/issues/23 |
| 49 | |
| 50 | ### Generator from `after()` and `all()` |
| 51 | |
| 52 | If the resulting components are ordered when {py:meth}`recurring_ical_events.CalendarQuery.after` or |
| 53 | {py:meth}`recurring_ical_events.CalendarQuery.all` is used. |
| 54 | The result is an iterator that returns the events in order. |
| 55 | |
| 56 | ```python |
| 57 | for event in recurring_ical_events.of(an_icalendar_object).after(datetime.datetime.now()): |
| 58 | print(event["DTSTART"]) # The start is ordered |
| 59 | ``` |
| 60 | |
| 61 | ## Timezones and floating time |
| 62 | |
| 63 | This library makes a distinction between floating time and times with timezones. |
| 64 | |
| 65 | Examples: |
| 66 | |
| 67 | * Event 1 happes at 12:00 in Singapore and event 2 on the same day at 12:00 in New York. |
| 68 | |
| 69 | * If you query that day without timezone, you will get both events. |
| 70 | * If you query 12:00 - 13:00 without timezone, you will get both events. |
| 71 | * If you query 12:00 - 13:00 in `Asia/Singapore`, you will only get event 1. |
| 72 | * If you query 12:00 - 13:00 in `America/New_York`, you will only get event 2. |
| 73 | |
| 74 | * If an event happens at night in floating time (without timezone) and |
| 75 | you query that day it will appear regardless of the timezone of the query. |
| 76 | Which is at different times in different timezones. |
| 77 | |
| 78 | * {py:class}`icalendar.cal.Alarm` has a `TRIGGER` which is in UTC. |
| 79 | The timezone to compute that for alarms relative to floating events will be taken |
| 80 | from the start and stop arguments. |
| 81 | |
| 82 | ## Pagination |
| 83 | |
| 84 | For ease of use, pagination has been introduced. |
| 85 | These are the pages returned by the query. |
| 86 | |
| 87 | ```{eval-rst} |
| 88 | .. automodule:: recurring_ical_events.pages |
| 89 | :members: |
| 90 | ``` |
| 91 | |
| 92 | ## Complete API |
| 93 | |
| 94 | ```{eval-rst} |
| 95 | |
| 96 | .. automodule:: recurring_ical_events |
| 97 | :show-inheritance: |
| 98 | :members: |
| 99 | :exclude-members: CalendarQuery, of, OccurrenceID |
| 100 | |
| 101 | .. automodule:: recurring_ical_events.types |
| 102 | :members: |
| 103 | |
| 104 | .. autoclass:: recurring_ical_events.OccurrenceID |
| 105 | |
| 106 | .. automethod:: to_string |
| 107 | .. automethod:: from_string |
| 108 | .. automethod:: from_occurrence |
| 109 | |
| 110 | ``` |