betweenDate Query filter that SoftLayer_EventLog likes

    :param string start: lower bound date in mm/dd/yyyy format
    :param string end: upper bound date in mm/dd/yyyy format
    :param string utc: utc offset. Defaults to '+0000'
14459
def event_log_filter_between_date(start, end, utc):
    
    return {
        'operation': 'betweenDate',
        'options': [
            {'name': 'startDate', 'value': [format_event_log_date(start, utc)]},
            {'name': 'endDate', 'value': [format_event_log_date(end, utc)]}
        ]
    }
700128
def ib_duration_str(start_date=None):
    
    now = datetime.datetime.utcnow()

    if is_number(start_date):
        diff = now - datetime.datetime.fromtimestamp(float(start_date))
    elif isinstance(start_date, str):
        diff = now - parse_date(start_date)
    elif isinstance(start_date, datetime.datetime):
        diff = now - start_date
    else:
        return None

    # get diff
    second_diff = diff.seconds
    day_diff = diff.days

    # small diff?
    if day_diff < 0 or second_diff < 60:
        return None

    # return str(second_diff)+ " S"
    if day_diff == 0 and second_diff > 1:
        return str(second_diff) + " S"
    if 31 > day_diff > 0:
        return str(day_diff) + " D"
    if 365 > day_diff > 31:
        return str(ceil(day_diff / 30)) + " M"

    return str(ceil(day_diff / 365)) + " Y"
820873
public static long betweenMs(Date beginDate, Date endDate) {
		return new DateBetween(beginDate, endDate).between(DateUnit.MS);
	}
1125282
def set_date_range(self, start=None, end=None):
        
        start = self._start if start is None else pd.to_datetime(start)
        end = self._end if end is None else pd.to_datetime(end)
        self._update(self._prices.loc[start:end])
712744
def date_time_ad(self, tzinfo=None, end_datetime=None, start_datetime=None):
        

        # 1970-01-01 00:00:00 UTC minus 62135596800 seconds is
        # 0001-01-01 00:00:00 UTC.  Since _parse_end_datetime() is used
        # elsewhere where a default value of 0 is expected, we can't
        # simply change that class method to use this magic number as a
        # default value when None is provided.

        start_time = -62135596800 if start_datetime is None else self._parse_start_datetime(start_datetime)
        end_datetime = self._parse_end_datetime(end_datetime)

        ts = self.generator.random.randint(start_time, end_datetime)
        # NOTE: using datetime.fromtimestamp(ts) directly will raise
        #       a "ValueError: timestamp out of range for platform time_t"
        #       on some platforms due to system C functions;
        #       see http://stackoverflow.com/a/10588133/2315612
        # NOTE: On windows, the lowest value you can get from windows is 86400
        #       on the first day. Known python issue:
        #       https://bugs.python.org/issue30684
        return datetime(1970, 1, 1, tzinfo=tzinfo) + timedelta(seconds=ts)
586041
def events_for_date_range(start_d, end_d, find_options = {})
      self.scoped(find_options).find(
        :all,
        :conditions => [ "(? <= #{self.quoted_table_name}.#{self.end_at_field}) AND (#{self.quoted_table_name}.#{self.start_at_field}< ?)", start_d.to_time.utc, end_d.to_time.utc ],
        :order => "#{self.quoted_table_name}.#{self.start_at_field} ASC"
      )
    end
1075584
public static <D extends Comparable> NumberExpression<Integer> datediff(DatePart unit,
            DateExpression<D> start, DateExpression<D> end) {
        return Expressions.numberOperation(Integer.class, DATE_DIFF_OPS.get(unit), start, end);
    }
1334497
def query_by_user(self, user_id, end_time=None, start_time=None):
        
        path = {}
        data = {}
        params = {}

        # REQUIRED - PATH - user_id
        """ID"""
        path["user_id"] = user_id

        # OPTIONAL - start_time
        """The beginning of the time range from which you want events."""
        if start_time is not None:
            params["start_time"] = start_time

        # OPTIONAL - end_time
        """The end of the time range from which you want events."""
        if end_time is not None:
            params["end_time"] = end_time

        self.logger.debug("GET /api/v1/audit/authentication/users/{user_id} with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/audit/authentication/users/{user_id}".format(**path), data=data, params=params, no_data=True)
496760
def daterange(value, details=False):
    ''''''
    if not isinstance(value, db.DateRange):
        raise ValueError('daterange only accept db.DateRange as parameter')

    if details:
        return daterange_with_details(value)

    date_format = 'YYYY'

    delta = value.end - value.start
    start, end = None, None
    start = format_date(value.start, date_format)
    if delta.days > 365:
        end = format_date(value.end, date_format)

    return '{start!s}–{end!s}'.format(start=start, end=end) if end else start
1050985
public final void setStartDate(Date startDate) {
                if (this.startDate == null || !this.startDate.equals(startDate)) {
                        if (startDate != null && endDate != null && endDate.before(startDate)) {
                                throw new ParameterException("The start date must be before the end date of the filter.");
                        }
                        this.startDate = startDate;
                        setChanged();
                        notifyObservers();
                }
        }
182613
def format_event_log_date(date_string, utc):
    
    user_date_format = "%m/%d/%Y"

    user_date = datetime.datetime.strptime(date_string, user_date_format)
    dirty_time = user_date.isoformat()

    if utc is None:
        utc = "+0000"

    iso_time_zone = utc[:3] + ':' + utc[3:]
    cleaned_time = "{}.000000{}".format(dirty_time, iso_time_zone)

    return cleaned_time
1097481
function(startDate, endDate) {
    var current = new Date(startDate);
    var end = new Date(endDate); 
    var dates = [];

    while(current <= end) {

        var m = current.getMonth() + 1;
        var d = current.getDate();
        var oneDate = [
            current.getFullYear(),
            m < 10 ? "0" + m : m,
            d < 10 ? "0" + d : d].join('-');

        dates.push(oneDate);
        current.setDate(current.getDate() + 1);
    }

    return dates;
}
258805
public static long getDaysBetweenIgnoreTime(String startDate, String endDate, Format format) {
        SimpleDateFormat localFormat = (SimpleDateFormat) format;
        try {
            java.util.Date startDay = localFormat.parse(startDate);
            java.util.Date endDay = localFormat.parse(endDate);
            return getDaysBetweenIgnoreTime(startDay, endDay);
        } catch (Exception e) {
            return 0;
        }
    }
708690
def daterange_start(value):
    ''''''
    if not value:
        return None
    elif isinstance(value, datetime):
        return value.date()
    elif isinstance(value, date):
        return value

    result = parse_dt(value).date()
    dashes = value.count('-')

    if dashes >= 2:
        return result
    elif dashes == 1:
        # Year/Month only
        return result.replace(day=1)
    else:
        # Year only
        return result.replace(day=1, month=1)
926612
public static String getDateCreatedTimeRangeFilterQuery(String searchField, long startTime, long endTime) {

        String sStartTime = null;
        String sEndTime = null;

        // Convert startTime to ISO 8601 format
        if ((startTime > Long.MIN_VALUE) && (startTime < Long.MAX_VALUE)) {
            sStartTime = CmsSearchUtil.getDateAsIso8601(new Date(startTime));
        }

        // Convert endTime to ISO 8601 format
        if ((endTime > Long.MIN_VALUE) && (endTime < Long.MAX_VALUE)) {
            sEndTime = CmsSearchUtil.getDateAsIso8601(new Date(endTime));
        }

        // Build Solr range string
        final String rangeString = CmsSearchUtil.getSolrRangeString(sStartTime, sEndTime);

        // Build Solr filter string
        return String.format("%s:%s", searchField, rangeString);
    }
1327408
def _rnd_datetime(self, start, end):
        
        return self.from_utctimestamp(
            random.randint(
                int(self.to_utctimestamp(start)),
                int(self.to_utctimestamp(end)),
            )
        )
907888
def query(self, start_date=None, end_date=None, ndays=None, metrics=[], dimensions=[], filters=None, segment=None, sort=[], start_index=1, max_results=10):
        
        if start_date:
            start_date = start_date
        elif getattr(self.args, 'start-date'):
            start_date = getattr(self.args, 'start-date')
        elif self.config.get('start-date', None):
            start_date = self.config['start-date']
        else:
            start_date = '2005-01-01'

        if end_date:
            end_date = end_date
        elif getattr(self.args, 'end-date'):
            end_date = getattr(self.args, 'end-date')
        elif self.config.get('end-date', None):
            end_date = self.config['end-date']
        elif ndays:
            end_date = self._ndays(start_date, ndays)
        elif self.args.ndays:
            end_date = self._ndays(start_date, self.args.ndays)
        elif self.config.get('ndays', None):
            end_date = self._ndays(start_date, self.config['ndays'])
        else:
            end_date = 'today' 

        if self.args.domain:
            domain = self.args.domain
        elif self.config.get('domain', None):
            domain = self.config['domain']
        else:
            domain = None

        if domain:
            domain_filter = 'ga:hostname==%s' % domain

            if filters:
                filters = '%s;%s' % (domain_filter, filters)
            else:
                filters = domain_filter

        if self.args.prefix:
            prefix = self.args.prefix
        elif self.config.get('prefix', None):
            prefix = self.config['prefix']
        else:
            prefix = None

        if prefix:
            prefix_filter = 'ga:pagePath=~^%s' % prefix 
                
            if filters:
                filters = '%s;%s' % (prefix_filter, filters)
            else:
                filters = prefix_filter

        return self.service.data().ga().get(
            ids='ga:' + self.config['property-id'],
            start_date=start_date,
            end_date=end_date,
            metrics=','.join(metrics) or None,
            dimensions=','.join(dimensions) or None,
            filters=filters,
            segment=segment,
            sort=','.join(sort) or None,
            start_index=str(start_index),
            max_results=str(max_results)
        ).execute()