marshaller/net/util.py

23 lines
468 B
Python
Raw Permalink Normal View History

2023-10-23 15:43:36 -04:00
import machine
import time
def datetime():
dt = machine.RTC().datetime()
return '{0:04d}-{1:02d}-{2:02d} {4:02d}:{5:02d}:{6:02d} UTC'.format(*dt)
def datetime_iso8601():
2023-10-23 15:43:36 -04:00
dt = machine.RTC().datetime()
return '{0:04d}-{1:02d}-{2:02d}T{4:02d}:{5:02d}:{6:02d}Z'.format(*dt)
def seconds_elapsed(ticks1, ticks2):
2023-10-23 15:43:36 -04:00
return time.ticks_diff(ticks1, ticks2) / 1000
def milliseconds_elapsed(ticks1, ticks2):
2023-10-23 15:43:36 -04:00
return time.ticks_diff(ticks1, ticks2)