(now=None)
Tries to guess a report window based on the current time.
    This is super sketchy - will choose a close time to the hour or 30 minute mark or
    fail hard in the event the task is too far from those.

    Only looks forwards in time.
Tries to guess a report window based on the current time.
    This is super sketchy - will choose a close time to the hour or 30 minute mark or
    fail hard in the event the task is too far from those.
Tries to guess a report window based on the current time . This is super sketchy - will choose a close time to the hour or 30 minute mark or fail hard in the event the task is too far from those .
def guess_reporting_minute(now=None):
    """
    Tries to guess a report window based on the current time.
    This is super sketchy - will choose a close time to the hour or 30 minute mark or
    fail hard in the event the task is too far from those.

    Only looks forwards in time.
    """
    now = now or datetime.utcnow()
    window = 5

    for reporting_minute in [0, 15, 30, 45]:
        if reporting_minute <= now.minute <= reporting_minute + window:
            return reporting_minute

    raise ValueError("Couldn't guess reporting minute for time: {}".format(now))
def guess_reporting_minute ( now = None ) : now = now or datetime . utcnow ( ) window = 5 for reporting_minute in [ 0 , 15 , 30 , 45 ] : if reporting_minute <= now . minute <= reporting_minute + window : return reporting_minute raise ValueError ( "Couldn't guess reporting minute for time: {}" . format ( now ) )