Did I find the right examples for you? yes no

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)

        def get_sloted_start(initial, delta):
    if not isinstance(initial, datetime):
        initial = datetime.fromtimestamp(initial, utc)
    if not isinstance(delta, int) and not isinstance(delta, float):
        # Works with timedelta and relativedelta
        delta = int(initial.strftime('%s')) - int((initial-delta).strftime('%s'))
    kwargs = {
        'year': initial.year,
        'month': 1,
        'day': 1
    }
    if delta < 60*60*24:
        kwargs['day'] = initial.day
    if delta < 60*60:
        kwargs['hour'] = initial.hour
    if delta < 60*60*24*364:
        kwargs['month'] = initial.month
    return datetime(tzinfo=utc, **kwargs)
        


src/c/o/confine-controller-0.10.5/controller/apps/pings/tasks.py   confine-controller(Download)
from controller.utils import LockFile
from controller.utils.apps import is_installed
from controller.utils.time import group_by_interval, get_sloted_start
 
from .models import Ping
        for downsample in downsamples:
            period, delta = downsample
            end = get_sloted_start(now-period, period)
            pings = obj.pings.order_by('date').filter(date__lte=end)
            if ini: