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

Fix width for --noweekend option of calw and calm #826

Merged
merged 1 commit into from
Jan 29, 2025

Conversation

msalle
Copy link
Contributor

@msalle msalle commented Jan 29, 2025

This pull request fixes calculating the width when calw/calm is used with the option --noweekend

Details

The day_width was calculated assuming 7 days a week. This is of course not correct when --noweekend is set. The variable days was already calculated in _GraphEvents, so move it to instance level and set it in __init__() and use it to calculate the correct width.

Note that this issue already existed before the width argument was fixed in #825 : e0e126e#diff-bdae32b0ae73657fd85ec3f881c2bcce2a0bfa93febd682ccc2febbb711e9cb6L150

Output before

Using a terminal width of 106 for which can completely fill both for 5 days (5*20+6 = 106) and 7 days (7*14+8 = 106).

[root@5b33b3d3ea4a gcalcli]# gcalcli calm
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│January 2025                                                                                            │
├──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──────────────┤
│Sunday        │Monday        │Tuesday       │Wednesday     │Thursday      │Friday        │Saturday      │
├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
│              │              │              │01            │02            │03            │04            │
│              │              │              │              │              │              │              │
...
[root@5b33b3d3ea4a gcalcli]# gcalcli calm --noweekend
┌──────────────────────────────────────────────────────────────────────────┐
│January 2025                                                              │
├──────────────┬──────────────┬──────────────┬──────────────┬──────────────┤
│Monday        │Tuesday       │Wednesday     │Thursday      │Friday        │
├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
│              │              │01            │02            │03            │
│              │              │              │              │              │
...

Output after

[root@5b33b3d3ea4a gcalcli]# gcalcli calm
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│January 2025                                                                                            │
├──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──────────────┬──────────────┤
│Sunday        │Monday        │Tuesday       │Wednesday     │Thursday      │Friday        │Saturday      │
├──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──────────────┼──────────────┤
│              │              │              │01            │02            │03            │04            │
│              │              │              │              │              │              │              │
...
[root@5b33b3d3ea4a gcalcli]# gcalcli calm --noweekend
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│January 2025                                                                                            │
├────────────────────┬────────────────────┬────────────────────┬────────────────────┬────────────────────┤
│Monday              │Tuesday             │Wednesday           │Thursday            │Friday              │
├────────────────────┼────────────────────┼────────────────────┼────────────────────┼────────────────────┤
│                    │                    │01                  │02                  │03                  │
│                    │                    │                    │                    │                    │
...

day_width was calculated assuming 7 days a week. This is not correct when
noweekend is set. days was already calculated in _GraphEvents, so move it to
instance level and set it in __init__ and use it to calculate the correct width.
@dbarnett dbarnett merged commit 5810f4f into insanum:main Jan 29, 2025
10 checks passed
@dbarnett
Copy link
Collaborator

Thanks for the fix!

@msalle
Copy link
Contributor Author

msalle commented Jan 29, 2025

Thanks for the fix!

Thanks for the quick merge, and happy to contribute, it's a great tool!

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.

2 participants