adds docstrings to functions. adds several comments.
This commit is contained in:
@@ -8,6 +8,16 @@ Created on Wed Jun 21 13:58:42 2023
|
||||
|
||||
# create slices
|
||||
def get_Tslices(ts_beg, ts_end, no_slices):
|
||||
"""Splits the time-period between two points in time into #no_slices and returns start and end time of each slice period.
|
||||
|
||||
Args:
|
||||
ts_beg (datetime): Datetime start of overall period to be sliced.
|
||||
ts_end (datetime): Datetime end of overall period to be sliced.
|
||||
no_slices (int): number of slices. 24 e.g. will produce 24 start and end dates each.
|
||||
|
||||
Returns:
|
||||
list[dict[str:datetime|str]]: One dict for each containing 'beg_time' 'end_time' and 'suffix' (e.g. -slice1)
|
||||
"""
|
||||
from datetime import datetime
|
||||
from datetime import timedelta
|
||||
ts_beg = datetime.strptime(ts_beg, '%Y-%m-%dT%H:%M:%SZ')
|
||||
@@ -25,6 +35,16 @@ def get_Tslices(ts_beg, ts_end, no_slices):
|
||||
|
||||
# For log time conversions (seconds to days, hours, minutes)
|
||||
def convertTime(duration):
|
||||
"""Converts seconds to hours, minutes and seconds.
|
||||
|
||||
Args:
|
||||
duration (int): seconds
|
||||
|
||||
Returns:
|
||||
int: hours
|
||||
int: minutes
|
||||
int: seconds
|
||||
"""
|
||||
days, seconds = duration.days, duration.seconds
|
||||
hours = days * 24 + seconds // 3600
|
||||
minutes = (seconds % 3600) // 60
|
||||
|
||||
Reference in New Issue
Block a user