时间戳，格式为yyyy-MM-dd HH:mm:ss，时区为GMT+8
962418
function timestamp () {
  var now = new Date()
  var diff = now.getTimezoneOffset() + 480
  now = new Date(now.getTime() + diff * 60000)

  var year = now.getFullYear()
  var month = ('0' + (now.getMonth() + 1)).slice(-2)
  var day = ('0' + now.getDate()).slice(-2)
  var hour = ('0' + now.getHours()).slice(-2)
  var minutes = ('0' + now.getMinutes()).slice(-2)
  var seconds = ('0' + now.getSeconds()).slice(-2)

  var result = '' + year + '-' + month + '-' + day + ' ' + hour + ':' + minutes + ':' + seconds
  debug(result)
  return result
}
1310748
function TimeInterval(startHour, startMin, endHour, endMin){

	this.start = {
		hour: null,
		min: null
	};
	this.end = {
		hour: null,
		min: null
	};

	//效验时间合法性
	if(parseInt(startHour) !== startHour || startHour < 0 || startHour > 23 || 
		parseInt(startMin) !== startMin || startMin < 0 || startMin > 59 || 
		parseInt(endHour) !== endHour || endHour < 0 || endHour > 23 || 
		parseInt(endMin) !== endMin || endMin < 0 || endMin > 59){

		throw new Error('startHour or startMin or endHour or endMin is invalid');
	}

	this.start.hour = startHour + '';
	this.start.min  = startMin + '';
	this.end.hour   = endHour + '';
	this.end.min    = endMin + '';

}
183454
public static function getDayTimestamp($now = null, $offset = 8) {
        $now = $now === null ? time() : $now;
        
        $gtm0 = $now - ($now % 86400); // GTM 0
        
        $dayline = ($now - $gtm0) / 3600;
        
        // 时差跨天
        if ($dayline + $offset > 23) {
            return $gtm0 + 86400 + $offset * 3600 * - 1;
        } else {
            return $gtm0 + $offset * 3600 * - 1;
        }
    }
1307498
function (time) {
      var split = time.split(':');
      var hour = parseInt(split[0]);
      var mn = parseInt(split[1]);

      if (this.settings.hour === 12) {
        var matches = time.match(/([0-1]?[0-9]):?([0-5][0-9])?\s?(am|pm|p)?/);
        var ind = matches[3];
        if (!ind) {
          ind = 'am';
        }

        hour = parseInt(matches[1]);
        mn = parseInt(matches[2]);

        if (!mn) {
          mn = 0;
        }

        if (hour === 12 && ind === 'am') {
          hour = 0;
        }
        if (hour === 12 && (ind === 'pm' || ind === 'p')) {
          ind = 'am';
        }
        if (ind === 'pm' || ind === 'p') {
          hour += 12;
        }
      }

      var position = 0;
      position += hour * this.periodInterval;
      position += mn / 60 * this.periodInterval;

      if (Math.floor(position) !== position) {
        return -1;
      }

      return position;
    }
1038634
function send(data) {
  const url = `${host}/log/cli`;
  debug('send log for api = %s', url);
  setTimeout(() => {
    request.post(
      {
        url,
        json: true,
        form: data,
        timeout: 4000, //4s
      },
      (err, result) => {
        if (!err && result.body && result.body.code === 200) {
          debug('日志发送成功');
        } else {
          debug('日志发送失败', err || result.body);
          // 发送失败的话，就用retcode发送一下存起来
          __WPO.setConfig({ spmId: 'fie-api-error' });
          const logMsg = [];
          Object.keys(data).forEach(item => {
            logMsg.push(`${item}=${JSON.stringify(data[item])}`);
          });

          __WPO.log(logMsg.join('&'), 1);
        }
      }
    );
  }, 500);
}
429831
public function init()
    {
        /**
         * 设置默认时区
         */
        if ($this->timezone)
        {
            date_default_timezone_set($this->timezone);
        }

        /**
         * 设置地区信息（地域信息）
         */
        if ($this->locale)
        {
            setlocale(LC_ALL, $this->locale);
        }

        if ($this->charset && function_exists('mb_internal_encoding'))
        {
            mb_internal_encoding($this->charset);
        }

        /**
         * 当输入字符的编码是无效的，或者字符代码不存在于输出的字符编码中时，可以为其指定一个替代字符。
         *
         * @link http://www.php.net/manual/function.mb-substitute-character.php
         */
        mb_substitute_character('none');

        // 确保输入的数据安全
        $_GET = Security::sanitize($_GET);
        $_POST = Security::sanitize($_POST);
        $_COOKIE = Security::sanitize($_COOKIE);

        self::cleanComponents();
    }
392872
function now() {
		if (strtolower($this->timeReference) == 'gmt') {
			$now = time();
			$system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now));
			if (strlen($system_time) < 10) {
				$system_time = time();
			}
			return $system_time;
		} else {
			return time();
		}
	}
573927
def timestamp_datetime(self, timestamp):
        
        format = '%Y-%m-%d %H:%M:%S'
        # timestamp为传入的值为时间戳(10位整数)，如：1332888820
        timestamp = time.localtime(timestamp)
        ## 经过localtime转换后变成
        ## time.struct_time(tm_year=2012, tm_mon=3, tm_mday=28, tm_hour=6, tm_min=53, tm_sec=40, tm_wday=2, tm_yday=88, tm_isdst=0)
        # 最后再经过strftime函数转换为正常日期格式。
        return time.strftime(format, timestamp)
1069215
private String formatYmdHis(Date date) {
    Calendar ca = Calendar.getInstance(CHINA_ZONE, CHINA_LOCALE);
    ca.setTimeInMillis(date.getTime());
    StringBuilder sbd = new StringBuilder();
    sbd.append(ca.get(Calendar.YEAR)).append('-');
    int month = 1 + ca.get(Calendar.MONTH);
    if (month < 10) {
      sbd.append('0');
    }
    sbd.append(month).append('-');
    int day = ca.get(Calendar.DAY_OF_MONTH);
    if (day < 10) {
      sbd.append('0');
    }
    sbd.append(day).append(' ');
    int hour = ca.get(Calendar.HOUR_OF_DAY);
    if (hour < 10) {
      sbd.append('0');
    }
    sbd.append(hour).append(':');
    int minute = ca.get(Calendar.MINUTE);
    if (minute < 10) {
      sbd.append('0');
    }
    sbd.append(minute).append(':');
    int second = ca.get(Calendar.SECOND);
    if (second < 10) {
      sbd.append('0');
    }
    sbd.append(second);
    return sbd.toString();
  }
922125
function toLatLng()
	{
		$wgs84 = new ReferenceEllipsoid(ReferenceEllipsoid::WGS84_MAJ, ReferenceEllipsoid::WGS84_MIN);

		$UTM_F0	 = 0.9996;
		$a = $wgs84->maj;
		$eSquared = $wgs84->ecc;
		$ePrimeSquared = $eSquared / (1.0 - $eSquared);
		$e1 = (1 - sqrt(1 - $eSquared)) / (1 + sqrt(1 - $eSquared));

		$x = $this->easting - 500000.0;;
		$y = $this->northing;

		$zoneNumber = $this->lngZone;
		$zoneLetter = $this->latZone;

		$longitudeOrigin = ($zoneNumber - 1.0) * 6.0 - 180.0 + 3.0;

		// Correct y for southern hemisphere
		if ((ord($zoneLetter) - ord("N")) < 0) {
			$y -= 10000000.0;
		}

		$m = $y / $UTM_F0;

		$mu = $m
			/ ($a
			* (1.0
				- $eSquared / 4.0
				- 3.0 * $eSquared * $eSquared / 64.0
				- 5.0
				* pow($eSquared, 3.0)
				/ 256.0));

		$phi1Rad = $mu
			+ (3.0 * $e1 / 2.0 - 27.0 * pow($e1, 3.0) / 32.0) * sin(2.0 * $mu)
			+ (21.0 * $e1 * $e1 / 16.0 - 55.0 * pow($e1, 4.0) / 32.0)
			* sin(4.0 * $mu)
			+ (151.0 * pow($e1, 3.0) / 96.0) * sin(6.0 * $mu);

		$n = $a / sqrt(1.0 - $eSquared * sin($phi1Rad) * sin($phi1Rad));

		$t = tan($phi1Rad) * tan($phi1Rad);
		$c = $ePrimeSquared * cos($phi1Rad) * cos($phi1Rad);

		$r = $a
			* (1.0 - $eSquared)
			/ pow(
			1.0 - $eSquared * sin($phi1Rad) * sin($phi1Rad),
			1.5);

		$d = $x / ($n * $UTM_F0);

		$latitude = ($phi1Rad
			- ($n * tan($phi1Rad) / $r)
			* ($d * $d / 2.0
				- (5.0
				+ (3.0 * $t)
				+ (10.0 * $c)
				- (4.0 * $c * $c)
				- (9.0 * $ePrimeSquared))
				* pow($d, 4.0)
				/ 24.0
				+ (61.0
				+ (90.0 * $t)
				+ (298.0 * $c)
				+ (45.0 * $t * $t)
				- (252.0 * $ePrimeSquared)
				- (3.0 * $c * $c))
				* pow($d, 6.0)
				/ 720.0)) * (180.0 / pi());

		$longitude = $longitudeOrigin + (($d
			- (1.0 + 2.0 * $t + $c) * pow($d, 3.0) / 6.0
			+ (5.0
			- (2.0 * $c)
			+ (28.0 * $t)
			- (3.0 * $c * $c)
			+ (8.0 * $ePrimeSquared)
			+ (24.0 * $t * $t))
			* pow($d, 5.0)
			/ 120.0)
			/ cos($phi1Rad)) * (180.0 / pi());

		return new LatLng($latitude, $longitude);
	}
1236450
function (len, min, dataTypeName, chars) {
      // 疑是 id 字段
      if (utils.isLikeId(dataTypeName)) {
        return String(utils.getId());
      }
      // 对疑是 xxx time 或者 xxx date 的字段, 返回当前时间之前一个月内的随机时间
      if (utils.isLikeTime(dataTypeName) || utils.isLikeDate(dataTypeName)) {
        return String(Date.now() - this._getNum(2592000));
      }
      // 疑是 email 字段
      if (utils.isLikeEmail(dataTypeName)) {
        return this._getStr(9, 6) + '@' + this._getStr(5) + '.' + this._getStr(3, null, null, ALPHA_LOWER_CASE_CHARS);
      }
      // 疑是 url 字段
      if (utils.isLikeUrl(dataTypeName)) {
        return 'http://' + this._getStr(3, null, null, ALPHA_LOWER_CASE_CHARS) + '.' + this._getStr(5, 15, null, ALPHA_LOWER_CASE_CHARS) + '.' + this._getStr(2, 8, null, ALPHA_LOWER_CASE_CHARS);
      }
      len = len || 10;
      if (min != undefined) {
        len = this._getNum(len, min);
      }
      var i;
      var str = '';
      chars = chars || ALPHA_NUMERIC_CHARS;
      var charsCount = chars.length;
      for (i = 0; i < len; i++) {
        str += chars[Math.floor(Math.random() * charsCount)];
      }
      return str;
    }
491273
function( text ) {
			if(modules.utils.isString(text)){
				text = text.toLowerCase();
				text = modules.utils.trim( text );
				// start with timezone char
				if( text.match(':') && ( modules.utils.startWith(text, 'z') || modules.utils.startWith(text, '-')  || modules.utils.startWith(text, '+') )) {
					return true;
				}
				// has ante meridiem or post meridiem
				if( text.match(/^[0-9]/) &&
					( this.hasAM(text) || this.hasPM(text) )) {
					return true;
				}
				// contains time delimiter but not datetime delimiter
				if( text.match(':') && !text.match(/t|\s/) ) {
					return true;
				}

				// if it's a number of 2, 4 or 6 chars
				if(modules.utils.isNumber(text)){
					if(text.length === 2 || text.length === 4 || text.length === 6){
						return true;
					}
				}
			}
			return false;
		}
937394
def strtimezone ():
    
    if time.daylight:
        zone = time.altzone
    else:
        zone = time.timezone
    return "%+04d" % (-zone//SECONDS_PER_HOUR)
1109983
function ( src, dst, callback ){
      fs.exists( dst, function ( exists ){
          // 已存在
          if( exists ){
              callback( src, dst );
          }

          // 不存在
          else{
              fs.mkdir( dst, function (){
                  callback( src, dst );
              });
          }
      });
  }
1119497
private function writeNoise() {
        $codeSet = '2345678abcdefhijkmnpqrstuvwxyz';
        for ($i = 0; $i < 10; $i++) {
            //杂点颜色
            $noiseColor = imagecolorallocate($this->im, mt_rand(150, 225), mt_rand(150, 225), mt_rand(150, 225));
            for ($j = 0; $j < 5; $j++) {
                // 绘杂点
                imagestring($this->im, 5, mt_rand(-10, $this->imageW), mt_rand(-10, $this->imageH), $codeSet[ mt_rand(0, 29) ], $noiseColor);
            }
        }
    }
1027232
public function dailyAt($time)
    {
        $hm_arr = explode(':', strval($time));
        if (count($hm_arr) != 2) {
            throw new \InvalidArgumentException("定时任务定义错误：dailyAt接受的时间参数格式不合法");
        }
        $h = intval($hm_arr[0]);
        $m = intval($hm_arr[1]);
        if (! is_int($h) || $h < -1 || $h > 24) {
            throw new \InvalidArgumentException("定时任务定义错误：dailyAt接受的时间参数值不合法");
        }
        if (! is_int($m) || $m < 0 || $m > 60) {
            throw new \InvalidArgumentException("定时任务定义错误：dailyAt接受的时间参数值不合法");
        }

        $next_time = strtotime(date("Y-m-d {$time}:00"));
        if (time() > $next_time) {
            $next_time = strtotime(date("Y-m-d {$time}:00", strtotime("+1 day")));
        }
        $this->handleByTaskStatus($next_time);
    }
655705
public void norm_setCurRelated() {
        String[] time_grid = new String[6];
        time_grid = originalTimeBaseText.split("-");
        int[] ini = new int[6];
        for (int i = 0; i < 6; i++) {
            ini[i] = Integer.parseInt(time_grid[i]);
        }

        Calendar calendar = Calendar.getInstance();
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        calendar.set(ini[0], ini[1] - 1, ini[2], ini[3], ini[4], ini[5]);
        calendar.getTime();

        boolean[] flag = {false, false, false};//观察时间表达式是否因当前相关时间表达式而改变时间

        String rule = "前年";
        Pattern pattern = Pattern.compile(rule);
        Matcher match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[0] = true;
            calendar.add(Calendar.YEAR, -2);
        }

        rule = "去年";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[0] = true;
            calendar.add(Calendar.YEAR, -1);
        }

        rule = "今年";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[0] = true;
            calendar.add(Calendar.YEAR, 0);
        }

        rule = "明年";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[0] = true;
            calendar.add(Calendar.YEAR, 1);
        }

        rule = "后年";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[0] = true;
            calendar.add(Calendar.YEAR, 2);
        }

        rule = "上(个)?月";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[1] = true;
            calendar.add(Calendar.MONTH, -1);

        }

        rule = "(本|这个)月";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[1] = true;
            calendar.add(Calendar.MONTH, 0);
        }

        rule = "下(个)?月";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[1] = true;
            calendar.add(Calendar.MONTH, 1);
        }

        rule = "大前天";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            calendar.add(Calendar.DATE, -3);
        }

        rule = "(?<!大)前天";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            calendar.add(Calendar.DATE, -2);
        }

        rule = "昨";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            calendar.add(Calendar.DATE, -1);
        }

        rule = "今(?!年)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            calendar.add(Calendar.DATE, 0);
        }

        rule = "明(?!年)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            calendar.add(Calendar.DATE, 1);
        }

        rule = "(?<!大)后天";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            calendar.add(Calendar.DATE, 2);
        }

        rule = "大后天";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            calendar.add(Calendar.DATE, 3);
        }

        rule = "(?<=(上上(周|星期)))[1-7]";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            int week = Integer.parseInt(match.group());
            if (week == 7) {
                week = 1;
            } else {
                week++;
            }
            calendar.add(Calendar.WEEK_OF_MONTH, -2);
            calendar.set(Calendar.DAY_OF_WEEK, week);
        }

        rule = "(?<=((?<!上)上(周|星期)))[1-7]";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            int week = Integer.parseInt(match.group());
            if (week == 7) {
                week = 1;
            } else {
                week++;
            }
            calendar.add(Calendar.WEEK_OF_MONTH, -1);
            calendar.set(Calendar.DAY_OF_WEEK, week);
        }

        rule = "(?<=((?<!下)下(周|星期)))[1-7]";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            int week = Integer.parseInt(match.group());
            if (week == 7) {
                week = 1;
            } else {
                week++;
            }
            calendar.add(Calendar.WEEK_OF_MONTH, 1);
            calendar.set(Calendar.DAY_OF_WEEK, week);
        }

        rule = "(?<=(下下(周|星期)))[1-7]";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            int week = Integer.parseInt(match.group());
            if (week == 7) {
                week = 1;
            } else {
                week++;
            }
            calendar.add(Calendar.WEEK_OF_MONTH, 2);
            calendar.set(Calendar.DAY_OF_WEEK, week);
        }

        rule = "(?<=((?<!(上|下))(周|星期)))[1-7]";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            int week = Integer.parseInt(match.group());
            if (week == 7) {
                week = 1;
            } else {
                week++;
            }
            calendar.add(Calendar.WEEK_OF_MONTH, 0);
            calendar.set(Calendar.DAY_OF_WEEK, week);
        }

        String s = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(calendar.getTime());
        String[] time_fin = s.split("-");
        if (flag[0] || flag[1] || flag[2]) {
            _tp.tunit[0] = Integer.parseInt(time_fin[0]);
        }
        if (flag[1] || flag[2]) {
            _tp.tunit[1] = Integer.parseInt(time_fin[1]);
        }
        if (flag[2]) {
            _tp.tunit[2] = Integer.parseInt(time_fin[2]);
        }

    }