peterhinch / micropython-async

Application of uasyncio to hardware interfaces. Tutorial and code.
MIT License
739 stars 168 forks source link

Sched: Rework to use UTC functions #125

Closed rhermanklink closed 2 months ago

rhermanklink commented 2 months ago

This Pull Request changes the sched module from using the machine time-dependent functions localtime(), timemk() to the gmtime(), timegm() functions respectively, which use UTC. For timegm() a minimal implementation was added to the cron.py file. This would prevent items from being scheduled in a DST transition, as UTC does not do DST. This change makes the callers of schedule and cron need to use gmtime() and timegm() too, which the tests have been modified to do.

Along with this, a few minor changes were made to make the module also work on CPython, such as changing const(n) to n.

peterhinch commented 2 months ago

This module was designed for MicroPython which normally runs on "bare metal" microcontrollers with no underlying OS, and in many cases no network connectivity. Consequently time support is limited to the time reported by the hardware RTC. Consequently the MicroPython time library does not support some of the methods you are using.

I can see that what you have done is useful to CPython users, and you may want to promote and maintain your own fork, but I can't accept this for MicroPython users. Sorry.