Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
takes a list of qdatetime objects and returns the difference from every object respect to the first one
vl = iface.activeLayer()
s = 0
l = []
for i, j in enumerate(vl.getFeatures()):
l.append(j['time'].toPyDateTime())
ll = []
for i, j in enumerate(l):
if i == 0:
ll.append(0)
try:
diff = l[i+1] - l[0]
# maggiore di un minuto e minore di un ora allora scrivi minuti
if diff.seconds > 60 and diff.seconds < 3600:
val = diff.seconds / 60
ll.append(val)
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment