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)
|
|
|
|
|
|
|
|
|
2023-10-27 17:48:42 -04:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
2023-10-27 17:48:42 -04:00
|
|
|
def seconds_elapsed(ticks1, ticks2):
|
2023-10-23 15:43:36 -04:00
|
|
|
return time.ticks_diff(ticks1, ticks2) / 1000
|
|
|
|
|
2023-10-27 17:48:42 -04:00
|
|
|
|
|
|
|
def milliseconds_elapsed(ticks1, ticks2):
|
2023-10-23 15:43:36 -04:00
|
|
|
return time.ticks_diff(ticks1, ticks2)
|