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 day-of-week string indexing to obey Python definition #27

Merged
merged 1 commit into from
Jun 13, 2022
Merged

Fix day-of-week string indexing to obey Python definition #27

merged 1 commit into from
Jun 13, 2022

Conversation

mew-cx
Copy link
Contributor

@mew-cx mew-cx commented Jun 11, 2022

Python defines "time.struct_time.tm_wday" (the day-of-week element) as
"range [0, 6], Monday is 0"; see:
https://docs.python.org/3/library/time.html#time.struct_time

When expanding the day-of-week integer to a string, the code incorrectly
used Sunday-as-0; probably a cut&paste error brought over from C code.

Python defines "time.struct_time.tm_wday" (the day-of-week element) as
"range [0, 6], Monday is 0"; see:
https://docs.python.org/3/library/time.html#time.struct_time

When expanding the day-of-week integer to a string, the code incorrectly
used Sunday-as-0; probably a cut&paste error brought over from C code.
@mew-cx
Copy link
Contributor Author

mew-cx commented Jun 11, 2022

Fix #26 for this repo

@tekktrik tekktrik requested a review from a team June 11, 2022 16:02
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

I confirmed this detail in the doc and tested the updated example which coincidentally has different behavior for today's between this fixed version and the current one.

I successfully tested the simpletest modified to today's date on Feather ESP32-S2 TFT. It correctly prints Monday with the new version.

@mew-cx Thanks for reporting this issue and submitting the fix here, as well as compiling the list of other places that may need the fix.

@FoamyGuy FoamyGuy merged commit 042c491 into adafruit:main Jun 13, 2022
@mew-cx mew-cx deleted the mewcx_day_of_week_fix branch June 13, 2022 22:40
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jun 14, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_DS1307 to 2.1.13 from 2.1.12:
  > Merge pull request adafruit/Adafruit_CircuitPython_DS1307#27 from mew-cx/mewcx_day_of_week_fix

Updating https://github.com/adafruit/Adafruit_CircuitPython_PCF8523 to 1.5.11 from 1.5.10:
  > Merge pull request adafruit/Adafruit_CircuitPython_PCF8523#26 from FoamyGuy/fix_day_names

Updating https://github.com/adafruit/Adafruit_CircuitPython_PCF8563 to 1.0.5 from 1.0.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_PCF8563#5 from FoamyGuy/fix_day_names

Updating https://github.com/adafruit/Adafruit_CircuitPython_asyncio to 0.5.11 from 0.5.10:
  > Merge pull request adafruit/Adafruit_CircuitPython_asyncio#19 from tekktrik/doc/add-docstrings

Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 2.5.7 from 2.5.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#51 from tannewt/update_readme
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