Advertisement
DeaD_EyE

micropython datetime lib

Mar 14th, 2022
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. # clonen, patchen, uploaden
  2.  
  3. git clone https://github.com/lorcap/upy-micropython-lib.git -b datetime
  4. cd upy-micropython-lib/python-stdlib/datetime/
  5. patch -p1 < localtz.patch
  6. rshell cp datetime.py /pyboard/lib/
  7.  
  8. # remote repl
  9. rshell repl
  10.  
  11. >>> from datetime import datetime, date, timezone, timedelta, time
  12. >>> datetime.now()
  13. datetime.datetime(2022, 3, 14, 13, 16, 58, 0, None, fold=0)
  14. >>> datetime.now() + timedelta(hours=1, minutes=1)
  15. datetime.datetime(2022, 3, 14, 14, 18, 31, 0, None, fold=0)
  16. >>> berlin = timezone(timedelta(hours=1), "Europe/Berlin")
  17. >>> datetime.now(berlin)
  18. datetime.datetime(2022, 3, 14, 14, 19, 34, 0, datetime.timezone(datetime.timedelta(microseconds=3600000000), 'Europe/Berlin'), fold=0)
  19. >>> datetime(2022, 1, 1) + timedelta(days=10)
  20. datetime.datetime(2022, 1, 11, 0, 0, 0, 0, None, fold=0)
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement