]> git.0d.be Git - pige-extractor.git/commitdiff
add support for subsecond cutting
authorFrédéric Péters <fpeters@0d.be>
Sun, 15 May 2016 13:41:21 +0000 (15:41 +0200)
committerFrédéric Péters <fpeters@0d.be>
Sun, 15 May 2016 14:16:17 +0000 (16:16 +0200)
download.cgi

index fbe7b07d0bfac12dec4032c1165a94c41471ba9c..e3b1a6972c889e7857b19ac05661c68c83943e5a 100755 (executable)
@@ -73,13 +73,13 @@ if end < start:
     end = end + datetime.timedelta(1)
 
 floor_start = start
-if floor_start.second:
-    floor_start = floor_start.replace(second=0)
+if floor_start.second or floor_start.microsecond:
+    floor_start = floor_start.replace(second=0, microsecond=0)
 floor_start = floor_start.replace(minute=floor_start.minute/15*15)
 
 ceil_end = end
-if ceil_end.second:
-    ceil_end = ceil_end.replace(minute=ceil_end.minute+1, second=0)
+if ceil_end.second or ceil_end.microsecond:
+    ceil_end = ceil_end.replace(minute=ceil_end.minute+1, second=0, microsecond=0)
 if ceil_end.minute%15:
     if ceil_end.minute / 15 == 3:
         ceil_end = ceil_end.replace(minute=0)
@@ -141,8 +141,8 @@ else:
 
 # trim
 command.append('trim')
-command.append('=%s' % (start - floor_start).seconds)
-command.append('=%s' % (end - floor_start).seconds)
+command.append('=%s.%06d' % ((start - floor_start).seconds, (start - floor_start).microseconds))
+command.append('=%s.%06d' % ((end - floor_start).seconds, (end - floor_start).microseconds))
 
 if '--test' in sys.argv:
     print ' '.join(command)