$rangeStart and $rangeEnd are assumed to be dates in UTC with 00:00:00 time.
541664
public function isWithinDayRange($rangeStart, $rangeEnd) {

    // Normalize our event's dates for comparison with the all-day range.
    $eventStart = stripTime($this->start);

    if (isset($this->end)) {
      $eventEnd = stripTime($this->end); // normalize
    }
    else {
      $eventEnd = $eventStart; // consider this a zero-duration event
    }

    // Check if the two whole-day ranges intersect.
    return $eventStart < $rangeEnd && $eventEnd >= $rangeStart;
  }
979573
function getDateDiff (startDate, endDate, rules) {
  var startTime, endTime, item, diffTime, rule, len, index
  var result = { done: false, time: 0 }
  startDate = toStringDate(startDate)
  endDate = endDate ? toStringDate(endDate) : new Date()
  if (baseExports.isDate(startDate) && baseExports.isDate(endDate)) {
    startTime = getDateTime(startDate)
    endTime = getDateTime(endDate)
    if (startTime < endTime) {
      diffTime = result.time = endTime - startTime
      rule = rules && rules.length > 0 ? rules : setupDefaults.dateDiffRules
      result.done = true
      for (index = 0, len = rule.length; index < len; index++) {
        item = rule[index]
        if (diffTime >= item[1]) {
          if (index === len - 1) {
            result[item[0]] = diffTime || 0
          } else {
            result[item[0]] = Math.floor(diffTime / item[1])
            diffTime -= result[item[0]] * item[1]
          }
        } else {
          result[item[0]] = 0
        }
      }
    }
  }
  return result
}
391597
@SuppressWarnings("deprecation")
    private void set_fields_from_millis(long millis)
    {
        if(millis < MINIMUM_TIMESTAMP_IN_MILLIS){
            throw new IllegalArgumentException("year is less than 1");
        }

        Date date = new Date(millis);

        // The Date getters return values in the Date's time zone (i.e. the system time zone).
        // The components need to be converted to UTC before being validated for exact ranges, because the offset
        // conversion can affect which values are considered valid. Simply verify that the values can fit in the
        // destination type here. If they do not, they would be out of range no matter the offset.
        _minute = requireByte(date.getMinutes(), "Minute");
        _second = requireByte(date.getSeconds(), "Second");
        _hour = requireByte(date.getHours(), "Hour");
        _day = requireByte(date.getDate(), "Day");
        _month = requireByte(date.getMonth() + 1, "Month");

        // Date does not correctly handle year values that represent year 0 or earlier in the system time zone through
        // getYear(). This case is detected and forced to zero.
        int offset = -date.getTimezoneOffset();
        if(offset < 0 && MINIMUM_TIMESTAMP_IN_MILLIS - offset > millis) {
            _year = 0;
        } else {
            _year = requireShort(date.getYear() + 1900, "Year");
        }

        // Now apply the offset to convert the components to UTC.
        apply_offset(offset);

        // Now that all components are in UTC, they may be validated for exact ranges.
        this._year    = checkAndCastYear(_year);
        this._month   = checkAndCastMonth(_month);
        this._day     = checkAndCastDay(_day, _year, _month);
        this._hour    = checkAndCastHour(_hour);
        this._minute  = checkAndCastMinute(_minute);
        this._second  = checkAndCastSecond(_second);
    }
129384
function(from, to) {
  config.backtest.daterange = {
    from: moment.unix(from).utc().format(),
    to: moment.unix(to).utc().format(),
  };
  util.setConfig(config);
}
946149
@SuppressWarnings("deprecation")
	public static boolean isTimeInRange(java.sql.Time start, java.sql.Time end, java.util.Date d) {
        d = new java.sql.Time(d.getHours(), d.getMinutes(), d.getSeconds());

        if (start == null || end == null) {
            return false;
        }

        if (start.before(end) && (!(d.after(start) && d.before(end)))) {
            return false;
        }

        if (end.before(start) && (!(d.after(end) || d.before(start)))) {
            return false;
        }
        return true;
    }
247413
function(d, val) {
    val = val > 86399 ? 0 : val;

    var next = later.date.next(
      later.Y.val(d),
      later.M.val(d),
      later.D.val(d) + (val <= later.t.val(d) ? 1 : 0),
      0,
      0,
      val);

    // correct for passing over a daylight savings boundry
    if(!later.date.isUTC && next.getTime() < d.getTime()) {
      next = later.date.next(
        later.Y.val(next),
        later.M.val(next),
        later.D.val(next),
        later.h.val(next),
        later.m.val(next),
        val + 7200);
    }

    return next;
  }
966860
function (t, use_UTC) {
		if (!use_UTC) {
			return [
				String("0" + t.getHours()).substr(-2),
				String("0" + t.getMinutes()).substr(-2)
			].join(":");
		}
		return [
			String("0" + t.getUTCHours()).substr(-2),
			String("0" + t.getUTCMinutes()).substr(-2)
		].join(":");
	}
653374
function parseDataToDateTime(parsed, parsedZone, opts, format, text) {
  const { setZone, zone } = opts;
  if (parsed && Object.keys(parsed).length !== 0) {
    const interpretationZone = parsedZone || zone,
      inst = DateTime.fromObject(
        Object.assign(parsed, opts, {
          zone: interpretationZone,
          // setZone is a valid option in the calling methods, but not in fromObject
          setZone: undefined
        })
      );
    return setZone ? inst : inst.setZone(zone);
  } else {
    return DateTime.invalid(
      new Invalid("unparsable", `the input "${text}" can't be parsed as ${format}`)
    );
  }
}
381187
function isMonthWithinRange(date, minDate, maxDate) {
       var month = date.getMonth();
       var year = date.getFullYear();

       return (!minDate || minDate.getFullYear() < year || minDate.getMonth() <= month) &&
        (!maxDate || maxDate.getFullYear() > year || maxDate.getMonth() >= month);
     }
995593
function time( start, end ) {
	var arr;
	var i;

	// Convert start and end times to JavaScript timestamps..
	start = ( new Date( start ) ).getTime();
	end = ( new Date( end ) ).getTime();

	// Add <1 day to ensure end time is included in time vector:
	end += 43200000; // half day [ms]

	// Create a linearly spaced date vector:
	arr = incrdatespace( start, end, 'day' );

	// Convert all date objects to JavaScript timestamps...
	for ( i = 0; i < arr.length; i++ ) {
		arr[ i ] = arr[ i ].getTime();
	}
	return arr;
}
970841
function setEndDate($date)
    {
        /*
          To indicate that a certificate has no well-defined expiration date,
          the notAfter SHOULD be assigned the GeneralizedTime value of
          99991231235959Z.

          -- http://tools.ietf.org/html/rfc5280#section-4.1.2.5
        */
        if (strtolower($date) == 'lifetime') {
            $temp = '99991231235959Z';
            $asn1 = new ASN1();
            $temp = chr(ASN1::TYPE_GENERALIZED_TIME) . $asn1->_encodeLength(strlen($temp)) . $temp;
            $this->endDate = new Element($temp);
        } else {
            if (!is_object($date) || !is_a($date, 'DateTime')) {
                $date = new DateTime($date, new DateTimeZone(@date_default_timezone_get()));
            }

            $this->endDate = $date->format('D, d M Y H:i:s O');
        }
    }
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
540900
def localize_time_range(begin: datetime, end: datetime, tz=None) -> (datetime, datetime):
    
    if not tz:
        tz = pytz.utc
    return tz.localize(begin), tz.localize(end)
715946
private static function cast(DateTimeRange $range)
	{
		$start = new Date($range->start());
		$end   = new Date($range->end());

		return new DateRange($start, $end);
	}
521847
function(inst, offset, curYear, curMonth) {
		var numMonths = this._getNumberOfMonths(inst);
		var date = this._daylightSavingAdjust(new Date(curYear,
			curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
		if (offset < 0)
			date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
		return this._isInRange(inst, date);
	}
1276574
function timePosition(day, time) { // both date objects. day holds 00:00 of current day
		day = cloneDate(day, true);
		if (time < addMinutes(cloneDate(day), minMinute)) {
			return 0;
		}
		if (time >= addMinutes(cloneDate(day), maxMinute)) {
			return slotTable.height();
		}
		var slotMinutes = opt('slotMinutes'),
			minutes = time.getHours()*60 + time.getMinutes() - minMinute,
			slotI = Math.floor(minutes / slotMinutes),
			slotTop = slotTopCache[slotI];
		if (slotTop === undefined) {
			slotTop = slotTopCache[slotI] =
				slotTable.find('tr').eq(slotI).find('td div')[0].offsetTop;
				// .eq() is faster than ":eq()" selector
				// [0].offsetTop is faster than .position().top (do we really need this optimization?)
				// a better optimization would be to cache all these divs
		}
		return Math.max(0, Math.round(
			slotTop - 1 + slotHeight * ((minutes % slotMinutes) / slotMinutes)
		));
	}
178986
function compareTimeZones(a, b) {
    if (typeof a !== 'string' || typeof b !== 'string') {
      return NaN;
    }

    return normalizeIso8601TimeZone(a) - normalizeIso8601TimeZone(b);
  }