Return the offset from UTC in CLF format.
@param {Date} date - The date
@return {String} The offset.
512258
function getCLFOffset(date) {
	const offset	= date.getTimezoneOffset().toString();
	const op		= offset[0] === '-' ? '-' : '+';
	let number		= offset.replace(op, '');

	while (number.length < 4) {
		number = `0${number}`;
	}

	return `${op}${number}`;
}
645268
@Override
    @Deprecated
    public void getOffsetFromLocal(long date,
            int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets) {
        offsets[0] = getRawOffset();
        int fields[] = new int[6];
        Grego.timeToFields(date, fields);
        offsets[1] = getOffset(GregorianCalendar.AD,
              fields[0], fields[1], fields[2],
              fields[3], fields[5]) - offsets[0];

        boolean recalc = false;

        // Now, we need some adjustment
        if (offsets[1] > 0) {
            if ((nonExistingTimeOpt & STD_DST_MASK) == LOCAL_STD
                || (nonExistingTimeOpt & STD_DST_MASK) != LOCAL_DST
                && (nonExistingTimeOpt & FORMER_LATTER_MASK) != LOCAL_LATTER) {
                date -= getDSTSavings();
                recalc = true;
            }
        } else {
            if ((duplicatedTimeOpt & STD_DST_MASK) == LOCAL_DST
                || (duplicatedTimeOpt & STD_DST_MASK) != LOCAL_STD
                && (duplicatedTimeOpt & FORMER_LATTER_MASK) == LOCAL_FORMER) {
                date -= getDSTSavings();
                recalc = true;
            }
        }

        if (recalc) {
            Grego.timeToFields(date, fields);
            offsets[1] = getOffset(GregorianCalendar.AD,
                    fields[0], fields[1], fields[2],
                    fields[3], fields[5]) - offsets[0];
        }
    }
108512
function() {
		var date = new Date();
		var day = date.getDate();
		var month = date.getMonth() + 1;
		var year = date.getFullYear();
		var hour = date.getHours();
		var minute = date.getMinutes();
		var second = date.getSeconds();
		if (day < 10) day = "0" + day;
		if (month < 10) month = "0" + month;
		if (hour < 10) hour = "0" + hour;
		if (minute < 10) minute = "0" + minute;
		if (second < 10) second = "0" + second;
		return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
	}
529053
function(date) {
			if(!date) {
				date = new Date();
			}

			if (this.time instanceof Date) {
				if (this.factory.countdown) {
					return Math.max(this.time.getTime()/1000 - date.getTime()/1000,0);
				} else {
					return date.getTime()/1000 - this.time.getTime()/1000 ;
				}
			} else {
				return this.time;
			}
		}
474246
public static Date offsetDate(Date date, int calendarUnit, int dateOffset) {
        if (date == null) {
            return null;
        }

        Calendar ca = Calendar.getInstance();
        ca.setTime(date);
        ca.add(calendarUnit, dateOffset);

        return ca.getTime();
    }
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()) + '"';
        }
812684
private String getFormattedDate(Date date) {
		String formattedDate = "";
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		try {
			formattedDate = ValueFactoryImpl.getInstance().createValue(cal).getString();
		} catch (Exception e) {
			// should never happen
			e.printStackTrace();
		}
		return formattedDate;
	}
1222793
function (date) {
                if (date instanceof Date === false) {
                    throw new ArgumentError(
                        Logger.logMessage(Logger.LEVEL_SEVERE, "SunPosition", "getAsGeographicLocation",
                            "missingDate"));
                }

                var celestialLocation = this.getAsCelestialLocation(date);
                return this.celestialToGeographic(celestialLocation, date);
            }
737465
function toAmzUtcString(date) {
  var pieces = new Date(date).toUTCString().match(/^(.+), (.+) (.+) (.+) (.+) GMT$/)
  return [pieces[1], pieces[3], pieces[2], pieces[5], 'UTC', pieces[4]].join(' ')
}
1000889
function parseDate(fmt, date) {
    var indexMap = {}; // contains reGroupPosition -> typeLetter or [typeLetter, value array]
    var reIndex = 1;
    var timezoneOffsetMatch;
    var timezoneIndex;
    var match;

    var format = replace(fmt, /^\?/);
    if (format!=fmt && !trim(date))
      return _null;

    if (match = /^\[([+-])(\d\d)(\d\d)\]\s*(.*)/.exec(format)) {
      timezoneOffsetMatch = match;
      format = match[4];
    }

    var parser = new RegExp(format.replace(/(.)(\1*)(?:\[([^\]]*)\])?/g, function(wholeMatch, placeholderChar, placeholderDigits, param) {
      if (/[dmhkyhs]/i.test(placeholderChar)) {
        indexMap[reIndex++] = placeholderChar;
        var plen = placeholderDigits.length+1;
        return "(\\d"+(plen<2?"+":("{1,"+plen+"}"))+")";
      }
      else if (placeholderChar == 'z') {
        timezoneIndex = reIndex;
        reIndex += 3;
        return "([+-])(\\d\\d)(\\d\\d)";
      }
      else if (/[Nna]/.test(placeholderChar)) {
        indexMap[reIndex++] = [placeholderChar, param && param.split(',')];
        return "([a-zA-Z\\u0080-\\u1fff]+)";
      }
      else if (/w/i.test(placeholderChar))
        return "[a-zA-Z\\u0080-\\u1fff]+";
      else if (/\s/.test(placeholderChar))
        return "\\s+";
      else
        return escapeRegExp(wholeMatch);
    }));

    if (!(match = parser.exec(date)))
      return undef;

    var ctorArgs = [0, 0, 0, 0, 0, 0,  0];
    for (var i = 1; i < reIndex; i++) {
      var matchVal = match[i];
      var indexEntry = indexMap[i];
      if (isList(indexEntry)) { // for a, n or N
        var placeholderChar = indexEntry[0];
        var mapEntry  = PARSE_DATE_MAP[placeholderChar];
        var ctorIndex = mapEntry[0];
        var valList = indexEntry[1] || mapEntry[1];
        var listValue = find(valList, function(v, index) { if (startsWith(matchVal.toLowerCase(), v.toLowerCase())) return index; });
        if (listValue == _null)
          return undef;
        if (placeholderChar == 'a')
          ctorArgs[ctorIndex] += listValue * 12;
        else
          ctorArgs[ctorIndex] = listValue;
      }
      else if (indexEntry) { // for numeric values (yHmMs)
        var value = parseFloat(matchVal);
        var mapEntry  = PARSE_DATE_MAP[indexEntry];
        if (isList(mapEntry))
          ctorArgs[mapEntry[0]] += value - mapEntry[1];
        else
          ctorArgs[mapEntry] += value;
      }
    }
    var d = new Date(ctorArgs[0], ctorArgs[1], ctorArgs[2], ctorArgs[3], ctorArgs[4], ctorArgs[5], ctorArgs[6]);
    return dateAdd(d, 'minutes', -getTimezone(timezoneOffsetMatch, 1, d) - getTimezone(match, timezoneIndex, d));
  }
188777
protected OffsetDateTime translateDate(Date date) {
    if (date == null) {
      return null;
    }
    
    return OffsetDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
  }
1139478
public static Date toUtcDate(TimeZone browserTZ, TimeZone targetTZ, Date localDate) {
        if (localDate == null) {
            return null;
        }

        long local = localDate.getTime();
        int targetOffsetFromUTC = targetTZ.getOffset(local);
        int browserOffsetFromUTC = browserTZ.getOffset(local);

        return new Date(local - targetOffsetFromUTC + browserOffsetFromUTC);
    }
636136
function(date) {
        var minDate = this.cfg.getProperty(DEF_CFG.MINDATE.key),
            maxDate = this.cfg.getProperty(DEF_CFG.MAXDATE.key),
            dm = DateMath;
        
        if (minDate) {
            minDate = dm.clearTime(minDate);
        } 
        if (maxDate) {
            maxDate = dm.clearTime(maxDate);
        }
    
        var clearedDate = new Date(date.getTime());
        clearedDate = dm.clearTime(clearedDate);
    
        return ((minDate && clearedDate.getTime() < minDate.getTime()) || (maxDate && clearedDate.getTime() > maxDate.getTime()));
    }
1001046
function CronDate (date) {
		this.milliseconds = date.getMilliseconds();
		this.seconds = date.getSeconds() + 1;
		this.minutes = date.getMinutes();
		this.hours = date.getHours();
		this.days = date.getDate();
		this.months  = date.getMonth();
		this.years = date.getFullYear();
	}
85996
public static CharSequence getJSDate(Date date)
	{
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);

		return getJSDate(calendar);
	}
742424
public static DateTime offsetMinute(Date date, int offset) {
		return offset(date, DateField.MINUTE, offset);
	}
517024
function isSt(date, testOffset) {
      date = date || new Date();
      var offset = testOffset || date.getTimezoneOffset();
      return offset == jsk.invertedSt();
    }