/* -------------------------------------------------------------------------- /* DOS Date format:
high|YYYYYYYm.mmmddddd.HHHHHMMM.MMMSSSSS|low
add 1980 to stored year
stored second should be doubled
 /* write JS date to buf as a DOS date
171464
function write_dos_date(buf, date) {
	if(typeof date === "string") date = new Date(date);
	var hms = date.getHours();
	hms = hms << 6 | date.getMinutes();
	hms = hms << 5 | (date.getSeconds()>>>1);
	buf.write_shift(2, hms);
	var ymd = (date.getFullYear() - 1980);
	ymd = ymd << 4 | (date.getMonth()+1);
	ymd = ymd << 5 | date.getDate();
	buf.write_shift(2, ymd);
}
384531
function (f) {
			var fmt = f || this.format
			, sepchar = getSeparator(fmt)
			, local = this;

			return _.map((fmt || 'yyyy mm dd').split(sepchar), function(part) {
				return local.template()[part];
			});
		}
458993
function (sValue) {
			return DateFormat.getDateInstance({
					pattern : "yyyy-MM-dd",
					strictParsing : true,
					UTC : true
				}).parse(sValue);
		}
1090627
function formatSingle(format, val) {
        var floatRegex = /f$/,
          decRegex = /\.([0-9])/,
          lang = defaultOptions.lang,
          decimals;

        if (floatRegex.test(format)) { // float
            decimals = format.match(decRegex);
            decimals = decimals ? decimals[1] : -1;
            if (val !== null) {
                val = numberFormat(
                  val,
                  decimals,
                  lang.decimalPoint,
                  format.indexOf(',') > -1 ? lang.thousandsSep : ''
                );
            }
        } else {
            val = dateFormat(format, val);
        }
        return val;
    }
409286
function (sValue) {
			var aMatches = mEdmType2RegExp.DateTimeOffset.exec(sValue);
			if (aMatches && aMatches[1] && aMatches[1].length > 4) {
				// "round" to millis, BEWARE of the dot!
				sValue = sValue.replace(aMatches[1], aMatches[1].slice(0, 4));
			}

			return DateFormat.getDateTimeInstance({
				pattern : "yyyy-MM-dd'T'HH:mm:ss.SSSX",
				strictParsing : true
			}).parse(sValue.toUpperCase());
		}
66631
function objectToDate(value, sm) {
  var d = Object.keys(value).reduce((x, k) => {
    var term = TERM[k.toLowerCase()];
    var v = value[k];
    if (term && !(term in x) && typeof v === 'number') {
      x[term] = v;
    } else {
      x.err = true;
    }
    return x;
  }, {});

  if (d.err) {
    return null;
  }

  var td = new Date();

  if (!('y' in d ) && !('m' in d ) && !('d' in d )) {
    d.y = td.getFullYear();
    d.m = td.getMonth() + 1;
    d.d = td.getDate();
  }

  var month = 'm' in d ? d.m : sm;
  var year  = 'y' in d ? d.y : td.getFullYear() - (month < sm ? 1 : 0);

  return new Date(
    year,
    month - 1,
    'd'  in d ? d.d  : 1,
    'h'  in d ? d.h  : 0,
    'i'  in d ? d.i  : 0,
    's'  in d ? d.s  : 0,
    'ms' in d ? d.ms : 0
  );
}
1103914
function(date) {    
            function format(number) {
                // Format integers to have at least two digits.
                return (number < 10) ? '0' + number : number;
            }
            return '"' + date.getFullYear() + '-' +
                    format(date.getMonth() + 1) + '-' +
                    format(date.getDate()) + 'T' +
                    format(date.getHours()) + ':' +
                    format(date.getMinutes()) + ':' +
                    format(date.getSeconds()) + '"';
        }
424349
function fidjDateParse(date) {
    if (!date || typeof date != 'string' || date == '') return false;
    // Date (choose 0 in date to force an error if parseInt fails)
    var yearS = parseInt(date.substr(0,4), 10) || 0;
    var monthS = parseInt(date.substr(5,2), 10) || 0;
    var dayS = parseInt(date.substr(8,2), 10) || 0;
    var hourS = parseInt(date.substr(11,2), 10) || 0;
    var minuteS = parseInt(date.substr(14,2),10) || 0;
    var secS = parseInt(date.substr(17,2),10) || 0;
    /*
    BEWARE : here are the ONLY formats supported by all browsers in creating a Date object
    var d = new Date(2011, 01, 07); // yyyy, mm-1, dd
    var d = new Date(2011, 01, 07, 11, 05, 00); // yyyy, mm-1, dd, hh, mm, ss
    var d = new Date("02/07/2011"); // "mm/dd/yyyy"
    var d = new Date("02/07/2011 11:05:00"); // "mm/dd/yyyy hh:mm:ss"
    var d = new Date(1297076700000); // milliseconds
    var d = new Date("Mon Feb 07 2011 11:05:00 GMT"); // ""Day Mon dd yyyy hh:mm:ss GMT/UTC
     */

    var newDate = new Date(yearS, monthS-1, dayS, hourS, minuteS, secS, 0);
    if ((newDate.getFullYear() !== yearS) || (newDate.getMonth() !== (monthS-1)) || (newDate.getDate() !== dayS)) {
        // Invalid date
        return false;
    }
    return newDate;
}
85403
static function UnixDate($v)
	{
	global $ADODB_sybase_mths;

		//Dec 30 2000 12:00AM
		if (!preg_match( "/([A-Za-z]{3})[-/\. ]+([0-9]{1,2})[-/\. ]+([0-9]{4})/"
			,$v, $rr)) return parent::UnixDate($v);

		if ($rr[3] <= TIMESTAMP_FIRST_YEAR) return 0;

		$themth = substr(strtoupper($rr[1]),0,3);
		$themth = $ADODB_sybase_mths[$themth];
		if ($themth <= 0) return false;
		// h-m-s-MM-DD-YY
		return  adodb_mktime(0,0,0,$themth,$rr[2],$rr[3]);
	}
441711
function parse_FILETIME(blob) {
	var dwLowDateTime = blob.read_shift(4), dwHighDateTime = blob.read_shift(4);
	return new Date(((dwHighDateTime/1e7*Math.pow(2,32) + dwLowDateTime/1e7) - 11644473600)*1000).toISOString().replace(/\.000/,"");
}
758423
function Date(Y, M, D, h, m, s, ms) {
                var length = arguments.length;
                var date;
                if (this instanceof NativeDate) {
                    var seconds = s;
                    var millis = ms;
                    if (hasSafariSignedIntBug && length >= 7 && ms > maxSafeUnsigned32Bit) {
                        // work around a Safari 8/9 bug where it treats the seconds as signed
                        var msToShift = Math.floor(ms / maxSafeUnsigned32Bit) * maxSafeUnsigned32Bit;
                        var sToShift = Math.floor(msToShift / 1e3);
                        seconds += sToShift;
                        millis -= sToShift * 1e3;
                    }
                    date = length === 1 && $String(Y) === Y ? // isString(Y)
                        // We explicitly pass it through parse:
                        new NativeDate(DateShim.parse(Y)) :
                        // We have to manually make calls depending on argument
                        // length here
                        length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) :
                        length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) :
                        length >= 5 ? new NativeDate(Y, M, D, h, m) :
                        length >= 4 ? new NativeDate(Y, M, D, h) :
                        length >= 3 ? new NativeDate(Y, M, D) :
                        length >= 2 ? new NativeDate(Y, M) :
                        length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) :
                                      new NativeDate();
                } else {
                    date = NativeDate.apply(this, arguments);
                }
                if (!isPrimitive(date)) {
                    // Prevent mixups with unfixed Date object
                    defineProperties(date, { constructor: DateShim }, true);
                }
                return date;
            }
476033
public static String yyyy_MM_dd(String strDate) {
        SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
        ParsePosition pos = new ParsePosition(0);
        Date strtodate = formatter.parse(strDate, pos);
        SimpleDateFormat formatter2 = new SimpleDateFormat(dateFormat);
        return formatter2.format(strtodate);
    }
159970
function format(data) {
    const time = util.formatTime(new Date());
    const outputArray = data.toString().replace(/^\s+|\s+$/g, '').split(/\s+/);
    const outputValues = [];
    for (let i = 0, counter = 0; i < outputArray.length; i++) {
        if (!isNaN(outputArray[i])) {
            outputValues[counter] = parseFloat(outputArray[i]);
            counter++;
        }
    }
    if (outputValues.length > 0) {
        return {
            date: time,
            disk: {
                kb_read: outputValues[9],
                kb_wrtn: outputValues[10],
                kb_read_per: outputValues[7],
                kb_wrtn_per: outputValues[8],
                tps: outputValues[6]
            },
            cpu: {
                cpu_user: outputValues[0],
                cpu_nice: outputValues[1],
                cpu_system: outputValues[2],
                cpu_iowait: outputValues[3],
                cpu_steal: outputValues[4],
                cpu_idle: outputValues[5]
            }
        };
    }
    return false;
}
648590
public static long decodeDateTime(int dosDate, int dosTime) {
        final Calendar cal = Calendar.getInstance();
        
        cal.set(Calendar.MILLISECOND, 0);
        cal.set(Calendar.SECOND, (dosTime & 0x1f) * 2);
        cal.set(Calendar.MINUTE, (dosTime >> 5) & 0x3f);
        cal.set(Calendar.HOUR_OF_DAY, dosTime >> 11);

        cal.set(Calendar.DATE, dosDate & 0x1f);
        cal.set(Calendar.MONTH, ((dosDate >> 5) & 0x0f) - 1);
        cal.set(Calendar.YEAR, 1980 + (dosDate >> 9));
        
        return cal.getTimeInMillis();
    }
43125
def dosdate(dosdate, dostime):
    
    try:
        t  = ord(dosdate[1]) << 8
        t |= ord(dosdate[0])
        day   = t & 0b0000000000011111
        month = (t & 0b0000000111100000) >> 5
        year  = (t & 0b1111111000000000) >> 9
        year += 1980

        t  = ord(dostime[1]) << 8
        t |= ord(dostime[0])
        sec     = t & 0b0000000000011111
        sec    *= 2
        minute  = (t & 0b0000011111100000) >> 5
        hour    = (t & 0b1111100000000000) >> 11

        return datetime(year, month, day, hour, minute, sec)
    except:
        return datetime.min
204724
function( format ) {

			this.setFormat(format);
			var output = '';

			if(this.dY  > -1) {
				output = this.dY;
				if(this.dM > 0 && this.dM < 13) {
					output += this.dsep + this.dM;
					if(this.dD > 0 && this.dD < 32) {
						output += this.dsep + this.dD;
						if(this.tH > -1 && this.tH < 25) {
							output += this.sep + this.toTimeString( this.format );
						}
					}
				}
				if(this.dDDD > -1) {
					output += this.dsep + this.dDDD;
				}
			} else if(this.tH > -1) {
				output += this.toTimeString( this.format );
			}

			return output;
		}
208549
function parseDate(s, ignoreTimezone) { // ignoreTimezone defaults to true
	if (typeof s == 'object') { // already a Date object
		return s;
	}
	if (typeof s == 'number') { // a UNIX timestamp
		return new Date(s * 1000);
	}
	if (typeof s == 'string') {
		if (s.match(/^\d+(\.\d+)?$/)) { // a UNIX timestamp
			return new Date(parseFloat(s) * 1000);
		}
		if (ignoreTimezone === undefined) {
			ignoreTimezone = true;
		}
		return parseISO8601(s, ignoreTimezone) || (s ? new Date(s) : null);
	}
	// TODO: never return invalid dates (like from new Date(<string>)), return null instead
	return null;
}