2016-11-10 07:33:23, 则返回2017-1-1 00:00:00
341024
public static Date nextYear(@NotNull final Date date) {
		return DateUtils.ceiling(date, Calendar.YEAR);
	}
34399
def crawl(self, *args, **kwargs):
        '''
        
        '''
        temp = tempfile.NamedTemporaryFile(mode='w+t')

        try:
            crawler = CrawlerScript()
            # 调试时可指定明确日期参数，如：date='20180423'
            crawler.crawl(output_file=temp.name, *args, **kwargs)

            temp.seek(0)
            content = json.loads(temp.read(), encoding='UTF-8')
        finally:
            temp.close()

        print('抓取完毕！')
        return content
1143453
function timerExpired() {
    let time = new Date()
      .getTime();
    if (shouldInvoke(time)) {
      return trailingEdge(time);
    }
    // 重启定时器
    timerId = setTimeout(timerExpired, remainingWait(time));
  }
14469
function UserInfo() {
	//使用者帳號(索引用)
	this.strAccount = "";
	//電子信箱
	this.strEmail = "";
	//信箱通知勾選
	this.bEmailNotify = false;
	//電話資料
	this.strPhone = "";
	//簡訊通知勾選
	this.bSMSNotify = false;
	//使用者名稱(暱稱?)
	this.strUserName = "";
	//語系控制
	this.strLanguages = "";
	//系統保護
	this.bSystemAegis = false;
	//登入次數
	this.iLoginCount = 0;
	//登入時間
	this.iLogin = 0;
	//最後登出時間
	this.iLastLogout = 0;
}
758335
function kind (date, compareTo) {
  date = this.toDatetime(date);
  compareTo = compareTo ? this.toDatetime(compareTo) : new Date();
  if (!date || !compareTo) {
    return '';
  }
  var diff =  (compareTo - date) / 1000;
  var surfix = 0 < diff ? '前' : '後';
  diff = Math.abs(diff);

  var i = POINTS.length - 1;
  var point;
  for(point = null;point = POINTS[i]; i--) {
    if (point[2] <= diff) {
      var x = parseInt(diff / point[0], 10) + (point[2] <= diff % point[0] ? 1 : 0);
      return x + point[1] + surfix;
    }
  }
  return 'たった今';
}
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);
    }
701925
function isOpen (date) {
  date = this.toDate(date);
  if (!date) {
    return null;
  }

  // 臨時営業・臨時休業
  var info = getDayInfo(this.dayInfo, date);
  if (info) {
    if (info.open) {
      return true;
    } else if (info.close) {
      return false;
    }
  }

  // 定休日判定
  if (this.isRegularHoliday(date)) {
    return false;
  }

  // 年末年始・お盆等の休みの判定
  if (this.isSeasonHoliday(date)) {
    return false;
  }

  // 祝日判定
  if (this.isHolidayClose(date)) {
    return false;
  }

  return true;
}
1099222
function replace(value) {

  // 漢数字、漢字、全角文字を半角数字に変換
  value = suji(value);

  // 和暦時西暦に変換
  value = value.replace(REG_ERA, (x, g, n, af) => {
    var era = ERA_MAP[g];
    return '' + (era.y + (n === '元' ?  1 : +n) - 1) + af;
  });

  // 午前午後を24時間表記に変換
  value = value.replace(REG_AMPM, (x, ampm, n) => {
    var pm = ampm === '午後' || ampm.toLowerCase() === 'pm';
    return pm ? +n + 12 : n;
  });

  return value;
}
562824
function showtime(created_at) {
    //补0
    function addzero(i) {
      return i<10 ? '0'+i : i
    }

    var time = new Date(created_at);
    var year = time.getFullYear();
    var month = time.getMonth() + 1;
    var date = time.getDate();
    var hour = addzero(time.getHours());
    var minute = addzero(time.getMinutes());

    var timestr = month + "月" + date + "日" + hour + ":" + minute;

    //360天前的微博显示年份
    var now = new Date();
    if (now.getTime() - time.getTime() > 31104000000) {
      return year + "年" + timestr;
    }
    return timestr;
  }
805131
protected boolean isLastTime(Date lastBackupTime) {
		if (lastBackupTime == null) {
			return true;
		}
		long diff = System.currentTimeMillis() - lastBackupTime.getTime();
		if (diff > (this.getInterval() * 1000L)) {
			// 10分钟前的时间算是上次备份时间
			return true;
		}
		return false;
	}
452223
function checkUplodingStatus() {
        checkTimer = setInterval(function () {
            if (uploading === 0 && checkTimer) {
                clearInterval(checkTimer);
                checkTimer = null;
                // 检测通过，开始检测50ms内是否还有新请求
                waitforNewUpload();
            }
        }, 10);
    }
88319
public void norm_setBaseRelated(){
		String [] time_grid=new String[6];
		time_grid=normalizer.getTimeBase().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="\\d+(?=天[以之]?前)";
		Pattern pattern=Pattern.compile(rule);
		Matcher match=pattern.matcher(Time_Expression);
		if(match.find())
		{
			flag[2] = true;
			int day = Integer.parseInt(match.group());
			calendar.add(Calendar.DATE, -day);
		}
		
		rule="\\d+(?=天[以之]?后)";
		pattern=Pattern.compile(rule);
		match=pattern.matcher(Time_Expression);
		if(match.find())
		{
			flag[2] = true;
			int day = Integer.parseInt(match.group());
			calendar.add(Calendar.DATE, day);
		}
		
		rule="\\d+(?=(个)?月[以之]?前)";
		pattern=Pattern.compile(rule);
		match=pattern.matcher(Time_Expression);
		if(match.find())
		{
			flag[1] = true;
			int month = Integer.parseInt(match.group());
			calendar.add(Calendar.MONTH, -month);
		}
		
		rule="\\d+(?=(个)?月[以之]?后)";
		pattern=Pattern.compile(rule);
		match=pattern.matcher(Time_Expression);
		if(match.find())
		{
			flag[1] = true;
			int month = Integer.parseInt(match.group());
			calendar.add(Calendar.MONTH, month);
		}
		
		rule="\\d+(?=年[以之]?前)";
		pattern=Pattern.compile(rule);
		match=pattern.matcher(Time_Expression);
		if(match.find())
		{
			flag[0] = true;
			int year = Integer.parseInt(match.group());
			calendar.add(Calendar.YEAR, -year);
		}
		
		rule="\\d+(?=年[以之]?后)";
		pattern=Pattern.compile(rule);
		match=pattern.matcher(Time_Expression);
		if(match.find())
		{
			flag[0] = true;
			int year = Integer.parseInt(match.group());
			calendar.add(Calendar.YEAR, year);
		}
		
		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]);
	}
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();
    }
817205
function watchOnFile(file, callback) {
  let lastIndex = 0
  let timer

  function read() {
    const stat = fs.statSync(file)

    if (stat.size !== lastIndex) {
      const fd = fs.openSync(file, 'r')
      const buffer = Buffer.alloc(stat.size - lastIndex)

      try {
        fs.readSync(fd, buffer, lastIndex, stat.size - lastIndex)
        const content = buffer.toString('utf8')
        lastIndex = stat.size

        callback(content)
      } catch (error) {
        // 从头读起
        lastIndex = 0
      }
    }

    timer = setTimeout(read, 200)
  }

  read()
  return function() {
    clearTimeout(timer)
  }
}
547795
def parse_stupid_date(c):
    
    start_time = {
        1: { "hour": 8, "minute": 40 },
        2: { "hour": 10, "minute": 10 },
        3: { "hour": 12, "minute": 15 },
        4: { "hour": 13, "minute": 45 },
        5: { "hour": 15, "minute": 15 },
        6: { "hour": 16, "minute": 45 },
    }

    end_time = {
        1: { "hour": 9, "minute": 55 },
        2: { "hour": 11, "minute": 25 },
        3: { "hour": 13, "minute": 30 },
        4: { "hour": 15, "minute": 0 },
        5: { "hour": 16, "minute": 30 },
        6: { "hour": 18, "minute": 0 },
    }

    periods = c['periods']
    dates = []
    while len(periods) > 0:
        m = re.search('((?:.・)*(?:.))([0-9])([,-])([0-9])', periods)
        assert(m is not None)

        groups = list(reversed(list(m.groups())))
        weekdays = groups.pop().split('・')
        period_start = int(groups.pop())

        if len(groups) == 0:
            sep = ','
            period_end = period_start
        else:
            sep = groups.pop()
            period_end = int(groups.pop())

        assert(sep in ['-', ','])
        assert(1 <= period_start <= 6)
        assert(1 <= period_end <= 6)

        if sep == ',':
            assert(period_end - period_start == 1)

        for weekday in weekdays:
            dt = get_start_date(c['modules'], weekday)
            dt_start = dt.replace(**start_time[period_start])
            dt_end = dt.replace(**end_time[period_end])
            dates.append((dt_start, dt_end))

        periods = periods[m.span()[1]:]

    return dates
138190
function runtime()
    {
        // 显示运行时间
        $return['time'] = number_format((microtime(true)-$this->env['runtime']['start']),4).'s';

        $startMem =  array_sum(explode(' ',$this->env['runtime']['mem']));
        $endMem   =  array_sum(explode(' ',memory_get_usage()));
        $return['memory'] = number_format(($endMem - $startMem)/1024).'kb';
        return $return;
    }
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;
    }