The minimum and maximum valid ISO week values for the year indicated.

@param {Date} d: The date indicating the year to find ISO values for
960530
function(d) {
    if (d.wyExtent) return d.wyExtent;

    // go to start of ISO week to get to the right year
    var year = later.dw.next(later.wy.start(d), 5),
        dwFirst = later.dw.val(later.Y.start(year)),
        dwLast = later.dw.val(later.Y.end(year));

    return (d.wyExtent = [1, dwFirst === 5 || dwLast === 5 ? 53 : 52]);
  }
140851
def iso_date(d) -> str:
        
        if isinstance(d, datetime):
            return d.isoformat()
        elif isinstance(d, date):
            return datetime.combine(d, datetime.min.time()).isoformat()
        else:
            try:
                datetime.strptime(d, '%Y-%m-%dT%H:%M:%S')
                return d
            except ValueError:
                try:
                    datetime.strptime(d, '%Y-%m-%d')
                    return d + "T00:00:00"
                except ValueError:
                    pass
        raise ISODateError("Can not convert value to ISO format for kg")
781643
def to_iso(dt):
    '''
    
    '''
    if isinstance(dt, datetime):
        return to_iso_datetime(dt)
    elif isinstance(dt, date):
        return to_iso_date(dt)
1088794
function (D) {
			var N = D.length;
			assert(N > 0, " X is empty? You must have some data!");
			// convert D to a (fast) typed array version
			var dists = zeros(N * N); // allocate contiguous array
			for (var i = 0; i < N; i++) {
				for (var j = i + 1; j < N; j++) {
					var d = D[i][j];
					dists[i * N + j] = d;
					dists[j * N + i] = d;
				}
			}
			this.P = d2p(dists, this.perplexity, 1e-4);
			this.N = N;
			this.initSolution(); // refresh this
		}
729617
function getValidInterval([min, max]) {
  let [validMin, validMax] = [min, max];

  // exchange
  if (min > max) {
    [validMin, validMax] = [max, min];
  }

  return [validMin, validMax];
}
1151056
function w3calgo(s, d) {
        var carry, temp, tempDays, e = {};
        //months
        temp = s.M + d.M;
        e.M = modulo(temp, 1, 13);
        carry = fQuotient(temp, 1, 13);
        // years
        e.Y = s.Y + d.Y + carry;
        // zone
        // e.Z = s.Z;
        // seconds 
        temp = s.S + d.S;
        e.S = modulo(temp, 60);
        carry = fQuotient(temp, 60);
        // minutes
        temp = s.m + d.m + carry;
        e.m = modulo(temp, 60);
        carry = fQuotient(temp, 60);
        // hours	
        temp = s.H + d.H + carry;
        e.H = modulo(temp, 24);
        carry = fQuotient(temp, 24);
        // days
        if (s.D > maximumDayInMonthFor(e.Y, e.M)) {
            tempDays = maximumDayInMonthFor(e.Y, e.M);
        } else if (s.D < 1) {
            tempDays = 1;
        } else {
            tempDays = s.D;
        }
        e.D = tempDays + d.D + carry;
        // start loop
        while (true) {
            if (e.D < 1) {
                e.D = e.D + maximumDayInMonthFor(e.D, e.M - 1);
                carry = -1;
            } else if (e.D > maximumDayInMonthFor(e.Y, e.M)) {
                e.D = e.D - maximumDayInMonthFor(e.Y, e.M);
                carry = 1;
            } else {
                break;
            }
            temp = e.M + carry;
            e.M = modulo(temp, 1, 13);
            e.Y = e.Y + fQuotient(temp, 1, 13);
        }
        e.Y = e.Y | 0;
        // in js dates month start at 0.
        e.M = e.M - 1 | 0;
        e.D = e.D | 0;
        e.H = e.H | 0;
        e.m = e.m | 0;
        e.S = e.S | 0;
        return new Date(e.Y, e.M, e.D, e.H, e.m, e.S);
    }
660126
function(d) {
		"use strict";

		if (this.options.weekStartOnMonday === false) {
			return d.getDay();
		}
		return d.getDay() === 0 ? 6 : (d.getDay()-1);
	}
829406
function isOptionalIntAbove(value, minimum) {

  if (_.isUndefined(value)) {
    return true;
  }

  if (!_.isInteger(value) || value < minimum) {
    return false;
  }

  return true;
}
228540
function randomDate(min, max) {
  min = min ? new Date(min) : new Date(0); // 1970-01-01

  if (max) {
    max = new Date(max);
  } else {
    max = new Date();
    max.setFullYear(max.getFullYear() + 10); // 10年后
  }

  return new Date(integer(max.getTime(), min.getTime()));
}
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;
  }
852580
function(d) {
    return d.wm || (d.wm =
      (later.D.val(d) +
      (later.dw.val(later.M.start(d)) - 1) + (7 - later.dw.val(d))) / 7);
  }
372091
function () {
            var t = this.dpop() >>> 0;
            var n = this.dpop() >>> 0;
            var nn = Long.fromValue(n, true);
            var tt = Long.fromValue(t, true);
            var ddd = nn.mul(tt);
            this.dpush(ddd.low);
            this.dpush(ddd.high);
        }
216989
function(d, val) {
    var month = later.date.prevRollover(d, val, later.dc, later.M),
        dcMax = later.dc.extent(month)[1];

    val = val > dcMax ? dcMax : val || dcMax;

    return later.dc.end(later.date.prev(
      later.Y.val(month),
      later.M.val(month),
      1 + (7 * (val - 1))
    ));
  }
822191
function(d, val) {
    var wyThur = later.dw.next(later.wy.start(d), 5),
        year = later.date.prevRollover(wyThur, val, later.wy, later.Y);

    // handle case where 1st of year is last week of previous month
    if(later.wy.val(year) !== 1) {
      year = later.dw.next(year, 2);
    }

    var wyMax = later.wy.extent(year)[1],
        wyEnd = later.wy.end(year);

    val = val > wyMax ? wyMax : val || wyMax;

    return later.wy.end(later.date.next(
        later.Y.val(wyEnd),
        later.M.val(wyEnd),
        later.D.val(wyEnd) + 7 * (val-1)
      ));
  }
855113
public static Date min(Date d1, Date d2)
   {
      Date result;
      if (d1 == null)
      {
         result = d2;
      }
      else
         if (d2 == null)
         {
            result = d1;
         }
         else
         {
            result = (d1.compareTo(d2) < 0) ? d1 : d2;
         }
      return result;
   }
532987
function normaliseDateTime(value) {
    if (_.isDate(value)) {
        return value;
    }

    // 'Shamnic' style heuristics
    var denormDate = /(\d{1,2})\/(\d{1,2})\/(\d{4})(?:\s+(\d{1,2})\:(\d{1,2})\s+(AM|PM)){0,1}/i;
    var partNormDate = /(\d{4})-(\d{1,2})-(\d{1,2})(?:\s+(\d{1,2})\:(\d{1,2})\s+(AM|PM)){0,1}/i;

    var partNorm = partNormDate.exec(value);

    var denorm = denormDate.exec(value);
    var align = function(value) {
        if (value && value.length === 1) {
            return '0' + value;
        } else {
            return value;
        }
    };

    if (denorm && !denorm[4]) { //Denormalized date only '31/12/2001'
        //Switch to yyyy-mm-dd
        return denorm[3] + '-' + align(denorm[1]) + '-' + align(denorm[2]);
    }

    if (denorm) { //Denormalized date and time '31/12/2001 3:30 PM'
        //Switch to yyyy-mm-ddZHH:mm
        return denorm[3] + '-' + align(denorm[1]) + '-' + align(denorm[2]) + 'Z' + ((denorm[6] === 'AM') ? denorm[4] : ((partNorm[4] === '12') ? '12' : (parseInt(partNorm[4]) + 12).toString())) + ':' + denorm[5];
    }

    if (partNorm && !partNorm[4]) { //Normalized date '2001-12-31'
        return value; // Do nothing
    }

    if (partNorm) { // Normalized date and denorm time '2001-12-31 3:30 PM'
        return partNorm[1] + '-' + align(partNorm[2]) + '-' + align(partNorm[3]) + 'T' + ((partNorm[6] === 'AM') ? partNorm[4] : ((partNorm[4] === '12') ? '12' : (parseInt(partNorm[4]) + 12).toString())) + ':' + partNorm[5] + ':00';
    }

    //WTF? Passthrough.
    return value;
}
1067795
function defaultFormat(d) {
  if ((0, _DateUtils.isDate)(d)) {
    var year = d.getFullYear();
    var month = '' + (d.getMonth() + 1);
    var day = '' + d.getDate();
    return year + '-' + month + '-' + day;
  }
  return '';
}