labpack/activity/moves.py
def _process_dates(self, timezone_offset, first_date, start, end, title, track_points=False):

        ''' a helper method to process datetime information for other requests

        :param timezone_offset: integer with timezone offset from user profile details
        :param first_date: string with ISO date from user profile details firstDate
        :param start: float with starting datetime for daily summaries
        :param end: float with ending datetime for daily summaries
        :param title: string with request method name
        :param track_points: [optional] boolean to provide detailed tracking of user movement
        :return: dictionary of parameters to add to request
        '''

    # validate inputs
        input_fields = {
            'timezone_offset': timezone_offset,
            'first_date': first_date,
            'start': start,
            'end': end
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)

    # validate datetimes
        max_time = 30 * 24 * 60 * 60 + 1
        max_days = '31'
        if track_points:
            max_days = '7'
            max_time = 6 * 24 * 60 * 60 + 1
        from time import time
        end_ISO = ''
        start_ISO = ''
        if end:
            if end > time():
                raise ValueError('%s(end=%s) datetime must not be in the future.' % (title, end))
            end_ISO = self._convert_dt(end, timezone_offset)
        if start:
            start_ISO = self._convert_dt(start, timezone_offset)
            if start_ISO < first_date:
                raise ValueError("%s(start=%s) datetime must not precede user signup first date." % (title, start))
        if start and end:
            if start > end:
                raise ValueError('%s(start=%s) must be a datetime before end=%s.' % (title, start, end))
            if end - start > max_time:
                raise ValueError('%s(start=%s, end=%s) must not be more than %s days apart.' % (title, start, end, max_days))

    # construct request parameters
        request_parameters = {}
        if not start_ISO and not end_ISO:
            request_parameters['pastDays'] = max_days
        else:
            if start_ISO and not end_ISO:
                end_dt = start + max_time
                current_ISO = self._convert_dt(time(), timezone_offset)
                end_ISO = self._convert_dt(end_dt, timezone_offset)
                if current_ISO < end_ISO:
                    end_ISO = current_ISO
            elif end_ISO and not start_ISO:
                start_dt = end - max_time
                start_ISO = self._convert_dt(start_dt, timezone_offset)
                if start_ISO < first_date:
                    start_ISO = first_date
            request_parameters['from'] = start_ISO
            request_parameters['to'] = end_ISO

        return request_parameters
 a helper method to process datetime information for other requests

        :param timezone_offset: integer with timezone offset from user profile details
        :param first_date: string with ISO date from user profile details firstDate
        :param start: float with starting datetime for daily summaries
        :param end: float with ending datetime for daily summaries
        :param title: string with request method name
        :param track_points: [optional] boolean to provide detailed tracking of user movement
        :return: dictionary of parameters to add to request
        
a helper method to process datetime information for other requests
a helper method to process datetime information for other requests
def _process_dates(self, timezone_offset, first_date, start, end, title, track_points=False):
        input_fields = {
            'timezone_offset': timezone_offset,
            'first_date': first_date,
            'start': start,
            'end': end
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)
        max_time = 30 * 24 * 60 * 60 + 1
        max_days = '31'
        if track_points:
            max_days = '7'
            max_time = 6 * 24 * 60 * 60 + 1
        from time import time
        end_ISO = ''
        start_ISO = ''
        if end:
            if end > time():
                raise ValueError('%s(end=%s) datetime must not be in the future.' % (title, end))
            end_ISO = self._convert_dt(end, timezone_offset)
        if start:
            start_ISO = self._convert_dt(start, timezone_offset)
            if start_ISO < first_date:
                raise ValueError("%s(start=%s) datetime must not precede user signup first date." % (title, start))
        if start and end:
            if start > end:
                raise ValueError('%s(start=%s) must be a datetime before end=%s.' % (title, start, end))
            if end - start > max_time:
                raise ValueError('%s(start=%s, end=%s) must not be more than %s days apart.' % (title, start, end, max_days))
        request_parameters = {}
        if not start_ISO and not end_ISO:
            request_parameters['pastDays'] = max_days
        else:
            if start_ISO and not end_ISO:
                end_dt = start + max_time
                current_ISO = self._convert_dt(time(), timezone_offset)
                end_ISO = self._convert_dt(end_dt, timezone_offset)
                if current_ISO < end_ISO:
                    end_ISO = current_ISO
            elif end_ISO and not start_ISO:
                start_dt = end - max_time
                start_ISO = self._convert_dt(start_dt, timezone_offset)
                if start_ISO < first_date:
                    start_ISO = first_date
            request_parameters['from'] = start_ISO
            request_parameters['to'] = end_ISO
        return request_parameters
def _process_dates ( self , timezone_offset , first_date , start , end , title , track_points = False ) : input_fields = { 'timezone_offset' : timezone_offset , 'first_date' : first_date , 'start' : start , 'end' : end } for key , value in input_fields . items ( ) : object_title = '%s(%s=%s)' % ( title , key , str ( value ) ) self . fields . validate ( value , '.%s' % key , object_title ) max_time = 30 * 24 * 60 * 60 + 1 max_days = '31' if track_points : max_days = '7' max_time = 6 * 24 * 60 * 60 + 1 from time import time end_ISO = '' start_ISO = '' if end : if end > time ( ) : raise ValueError ( '%s(end=%s) datetime must not be in the future.' % ( title , end ) ) end_ISO = self . _convert_dt ( end , timezone_offset ) if start : start_ISO = self . _convert_dt ( start , timezone_offset ) if start_ISO < first_date : raise ValueError ( "%s(start=%s) datetime must not precede user signup first date." % ( title , start ) ) if start and end : if start > end : raise ValueError ( '%s(start=%s) must be a datetime before end=%s.' % ( title , start , end ) ) if end - start > max_time : raise ValueError ( '%s(start=%s, end=%s) must not be more than %s days apart.' % ( title , start , end , max_days ) ) request_parameters = { } if not start_ISO and not end_ISO : request_parameters [ 'pastDays' ] = max_days else : if start_ISO and not end_ISO : end_dt = start + max_time current_ISO = self . _convert_dt ( time ( ) , timezone_offset ) end_ISO = self . _convert_dt ( end_dt , timezone_offset ) if current_ISO < end_ISO : end_ISO = current_ISO elif end_ISO and not start_ISO : start_dt = end - max_time start_ISO = self . _convert_dt ( start_dt , timezone_offset ) if start_ISO < first_date : start_ISO = first_date request_parameters [ 'from' ] = start_ISO request_parameters [ 'to' ] = end_ISO return request_parameters
a helper method to process datetime information for other requests
a helper method to process datetime information for other requests
''' a helper method to process datetime information for other requests

        :param timezone_offset: integer with timezone offset from user profile details
        :param first_date: string with ISO date from user profile details firstDate
        :param start: float with starting datetime for daily summaries
        :param end: float with ending datetime for daily summaries
        :param title: string with request method name
        :param track_points: [optional] boolean to provide detailed tracking of user movement
        :return: dictionary of parameters to add to request
        ''' # validate inputs
 # validate datetimes
 # construct request parameters

dictionary of parameters to add to request
dictionary of parameters to add to request
self
timezone_offset
integer with timezone offset from user profile details
integer with timezone offset from user profile details
first_date
string with ISO date from user profile details firstDate
string with ISO date from user profile details firstDate
start
float with starting datetime for daily summaries
float with starting datetime for daily summaries
end
float with ending datetime for daily summaries
float with ending datetime for daily summaries
title
string with request method name
string with request method name
track_points
[optional] boolean to provide detailed tracking of user movement
[ optional ] boolean to provide detailed tracking of user movement