8000 New module `suntime` for sunrise and sunset time by lorcap · Pull Request #450 · micropython/micropython-lib · GitHub
[go: up one dir, main page]

Skip to content

New module suntime for sunrise and sunset time #450

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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

lorcap
Copy link
Contributor
@lorcap lorcap commented Sep 27, 2021

Approximated calculation of sunrise and sunset time. Adapted from https://github.com/SatAgro/suntime.

Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
@mattytrentini
Copy link
Contributor

This looks like a useful addition, however SatAgro/suntime is LGPL which is incompatible with micropython-lib's MIT license...

@lorcap
Copy link
Contributor Author
lorcap commented Sep 28, 2021

I started from scratch with the formula provided by Wikipedia's Sunrise equation and it works. I'll provide a new clean and neat code under MIT license in the following days.

Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
@lorcap
Copy link
Contributor Author
lorcap commented Oct 6, 2021

I just pushed a commit with the new module implementation. I rebased it on datetime branch (see PR #449) because it depends on that.

Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
@lorcap
Copy link
Contributor Author
lorcap commented Oct 31, 2021

Just rebased on top of datetime.

By matching the order of class methods used in Python's datetime, code
changes are easier to implement.

Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
`timedelta` resolution is now 1 nanosecond, instead of 1 second. The
module is now suitable for logging at microsecond scale and below. As a
bonus, `timedelta` can now handle deltas which span ±292 years (instead
of the previous ±68 years). The cost is 4 more bytes per instance.

Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
When adding a negative integral number of days, time's reminder was lost
and the result was one day less than expected.

Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
Signed-off-by: Lorenzo Cappelletti <lorenzo.cappelletti@gmail.com>
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
0