32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
'''
|
|
Created on Wed Jun 21 13:58:42 2023
|
|
|
|
@author: michael
|
|
'''
|
|
|
|
# create slices
|
|
def get_Tslices(ts_beg, ts_end, no_slices):
|
|
from datetime import datetime
|
|
from datetime import timedelta
|
|
ts_beg = datetime.strptime(ts_beg, '%Y-%m-%dT%H:%M:%SZ')
|
|
ts_end = datetime.strptime(ts_end, '%Y-%m-%dT%H:%M:%SZ')
|
|
ts_dif = (ts_end - ts_beg) / no_slices
|
|
time_slices = []
|
|
for i in range(no_slices):
|
|
time_slices.append(
|
|
{
|
|
'beg_time': (ts_beg + ts_dif * i).strftime('%Y-%m-%dT%H:%M:%SZ'),
|
|
'end_time': (ts_beg + ts_dif * i + ts_dif - timedelta(microseconds=1)).strftime('%Y-%m-%dT%H:%M:%SZ'),
|
|
'suffix': f'-slice{i+1}'
|
|
})
|
|
return time_slices
|
|
|
|
# For log time conversions (seconds to days, hours, minutes)
|
|
def convertTime(duration):
|
|
days, seconds = duration.days, duration.seconds
|
|
hours = days * 24 + seconds // 3600
|
|
minutes = (seconds % 3600) // 60
|
|
seconds = (seconds % 60)
|
|
return hours, minutes, seconds |