Skip to content

Instantly share code, notes, and snippets.

@Beormund
Beormund / daylightsaving.py
Last active November 12, 2023 09:16
Micropython module for converting UTC to local time using daylight saving policies.
import utime
# hemisphere [0 = Northern, 1 = Southern]
# week [0 = last week of month, 1..4 = first..fourth]
# month [1 = January; 12 = December]
# weekday [0 = Monday; 6 = Sunday] (day of week)
# hour (hour at which dst/std changes)
# timezone [-780..780] (offset from UTC in MINUTES - 780min / 60min=13hrs)
class Policy:
def __init__(self, hemisphere, week, month, weekday, hour, timezone):