odeevee / DS1302_CircuitPython

Quick and easy library for the DS1302 RTC on CircuitPython
MIT License
0 stars 1 forks source link

order of operators #2

Open ady-v opened 1 year ago

ady-v commented 1 year ago

https://github.com/odeevee/DS1302_CircuitPython/blob/bcc2d62094724813ae090d44a17d52773a8141c1/ds1302.py#L96

Thank you for sharing this useful piece of code. I had a problem with writing/reading the year. Please consider that the division will take place before the substraction and you need some paranthesis on row 96 of ds1302.py: byte_l[6] = (((dt.tm_year-2000) // 10) << 4) | (dt.tm_year-2000) % 10

fridayghost commented 5 months ago

Thank you @ady-v I have been scratching my head since last 2 hours for the incorrect year value. Your solution did the trick.