Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sign and weekday attributes to vWeekday components #750

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

david-venhoff
Copy link
Contributor

@david-venhoff david-venhoff commented Nov 25, 2024

This pr adds the sign and weekday properties to vWeekday components, so that users of this library don't have to manually parse these.

I decided to just make the existing variables available, but I could also combine sign and relative into one variable, if that is wanted.

Fixes: #749


📚 Documentation preview 📚: https://icalendar--750.org.readthedocs.build/

@coveralls
Copy link

coveralls commented Nov 25, 2024

Pull Request Test Coverage Report for Build 12054469339

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 20 of 20 (100.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.3%) to 96.355%

Files with Coverage Reduction New Missed Lines %
src/icalendar/tests/test_cli_tool.py 1 96.3%
Totals Coverage Status
Change from base Build 11994190464: 0.3%
Covered Lines: 4580
Relevant Lines: 4747

💛 - Coveralls

Copy link
Member

@niccokunzmann niccokunzmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I like your PR! I left a bot of feedback and I am wondering if the sign should be integrated into the relative variable. What are your thoughts on this?

Also, I am wondering what the sign means and since you care about the sign, I would hope you know and we can document it so others know how to use the fix.

Let me know what you think!
Thanks for the tests!

src/icalendar/prop.py Show resolved Hide resolved
src/icalendar/tests/prop/test_vWeekday.py Outdated Show resolved Hide resolved


def test_simple():
weekday = vWeekday("SU")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these examples from the tests.
We also have doctests.
If you add some examples to class definition, this will help people understand your fix and how to use this class.

Like:

>>> su = vWeekday("SU") # Sunday
>>> su
>>> su.weekday
>>> su.relative
>>> su.to_ical()

>>> th = vWeekday("2TH")  # second Thursday of the month?
>>> th
>>> th.weekday
>>> th.relative
>>> th.to_ical()

>>> fr = vWeekday("-1FR")  # last Friday of the month?
>>> fr
>>> fr.weekday
>>> fr.relative

I am writing this here because I would like your input: What does -1 mean in your view? Is it the last weekday of the month?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. For example, this rrule would repeat monthly on every last friday: FREQ=MONTHLY;BYDAY=-1FR. I think using a relative BYDAY value is also allowed with a yearly frequency (rfc, page 42)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to extend the rrule documentation, too. I would say though that I open another issue for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the docstring and added some doctests now :)

@david-venhoff
Copy link
Contributor Author

david-venhoff commented Nov 27, 2024

I have one more question: According to rfc 5545, the BYDAY attribute for recurrence rules can be followed by a bywdaylist. A bywdaylist can contain weekdaynum, and a weekdaynum is defined like this: weekdaynum = [[plus / minus] ordwk] weekday.
However, some other attributes (e.g. WKST) can only be followed by a simple weekday (without number prefix).

Wouldn't it make sense to have two different classes for weekdays then? One that only stores a weekday and one that stores a weekday and a number. Right now, icalendar always allows the number, I think.

@niccokunzmann niccokunzmann merged commit a8b1ca9 into collective:main Nov 27, 2024
18 checks passed
@niccokunzmann
Copy link
Member

I think, this is good. One can always create invalid files. this package does not check validity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] vWeekday does not make sign, weekday available
3 participants