************************************************************** 文字列 => 日時
198090
function stringToDate(value, sm) {
  value = value.trim();
  var r, y, m, d, h = 0, i = 0, s = 0, ms =0, len=0;

  if (r = value.match(BASE_FORMAT)) {
    return baseToDate(r);
  }

  // 変換
  value = replace(value);

  if (r = value.match(BASE_FORMAT)) {
    return baseToDate(r);
  }


  // 年+月のみ
  if (r = value.match(YYYYMM1) || value.match(YYYYMM2)) {
    return getValidDate(+r[1], +(r[2] || sm), 1, 0, 0, 0, 0);
  }

  var now = new Date();

  var timeskip = false;

  if (r = value.match(YYYYMMDD)) {
    y = +r[1];
    m = +(r[2] || sm);
    d = r[3] === '末' ? new Date(y, m, 0).getDate() : +(r[3] || 1);
    len = r[0].length;
    timeskip = !r[3];
  } else if (r = value.match(MMDD1) || value.match(MMDD2)) {
    m = +r[1];
    y = now.getFullYear() + (m < sm ? 1 : 0);
    d = r[2] === '末' ? new Date(y, m, 0).getDate() : +r[2];
    len = r[0].length;
  } else {
    y = now.getFullYear();
    m = now.getMonth() + 1;
    d = now.getDate();
  }

  if (r = value.match(HHIISSsss)) {
    h  = +r[1];
    i  = +(r[2] || 0);
    s  = +(r[3] || 0);
    ms = +(r[4] ? (r[4] + '00').slice(0, 3) : 0);
    len += timeskip ? 0 : r[0].length;
  }

  return value.length === len ? getValidDate(y, m, d, h, i, s, ms) : null;
}
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;
}
761293
function(arg) {
  var args = Array.isArray(arg) ? arg : Array.apply(null, arguments);
  lastMsgDate = new Date();
  fs.write(tempFile, JSON.stringify(args) + '\n', 'a');
}
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 'たった今';
}
49418
public static boolean beforeNow(String date, String format, DateUnit dateUnit) {
        logger.debug("指定日期为：{}", date);
        return calc(new Date(), parse(date, format), dateUnit) > 0;
    }
765189
function copyDir(srcPath, desPath, relative) {
    if(relative == undefined){
        relative = srcPath;
    }

    fs.readdir(srcPath, function (err, files) {
        files.forEach(function (fileName) {
            fs.stat(path.join(srcPath, fileName), function (err, stats) {
                if (err) {
                    console.log('[error] ', err);
                    return;
                }
                if (stats.isFile()) {
                    var relativePath = path.relative(relative, srcPath);
                    var replace = { win32: '..\\', linux: '../' };

                    var srcFile = path.normalize(srcPath + '/' + fileName);
                    var desFile = path.normalize(path.join(desPath,
                        relativePath.replace(replace[os.platform])) + '/' + fileName);
                    //console.log('src file:', srcFile);
                    //console.log('des file:', desFile);
                    createDir(srcFile,desFile);

                } else if (stats.isDirectory()) {
                    //第三个参数用于区分是否是递归开始，并且计算目标路径相对于给定路径的相对位置
                    copyDir(path.join(srcPath,fileName),desPath,relative);
                }
            });
        });
    });
}
611327
public static Date formatStringToDate(String argDateStr, String argFormat) throws Exception {
        if (argDateStr == null || argDateStr.trim().length() < 1) {
            throw new Exception("参数[日期]不能为空!");
        }
        String strFormat = argFormat;
        if (strFormat == null || strFormat.length() == 0) {
            strFormat = Y_M_D;
            if (argDateStr.length() > 16) {
                strFormat = Y_M_D_HMS;
            } else if (argDateStr.length() > 10) {
                strFormat = Y_M_D_HM;
            }
        }
        SimpleDateFormat sdfFormat = new SimpleDateFormat(strFormat);
        //严格模式
        sdfFormat.setLenient(false);
        try {
            return sdfFormat.parse(argDateStr);
        } catch (ParseException e) {
            throw new Exception(e);
        }
    }
97485
function()
        {
            // 如果导入了 pinyin_dict_firstletter.js
            if(pinyin_dict_firstletter)
            {
                dict.firstletter = pinyin_dict_firstletter;
            }
            // 如果导入了 pinyin_dict_notone.js
            if(window.pinyin_dict_notone)
            {
                dict.notone = {};
                dict.py2hz = pinyin_dict_notone; // 拼音转汉字
                for(var i in pinyin_dict_notone)
                {
                    var temp = pinyin_dict_notone[i];
                    for(var j=0, len=temp.length; j<len; j++)
                    {
                        if(!dict.notone[temp[j]]) dict.notone[temp[j]] = i; // 不考虑多音字
                    }
                }
            }
            // 如果导入了 pinyin_dict_withtone.js
            if(window.pinyin_dict_withtone)
            {
                dict.withtone = {}; // 汉字与拼音映射，多音字用空格分开，类似这种结构：{'大': 'da tai'}
                var temp = pinyin_dict_withtone.split(',');
                for(var i=0, len = temp.length; i<len; i++)
                {
                    // 这段代码耗时28毫秒左右，对性能影响不大，所以一次性处理完毕
                    dict.withtone[String.fromCharCode(i + 19968)] = temp[i]; // 这里先不进行split(' ')，因为一次性循环2万次split比较消耗性能
                }

                // 拼音 -> 汉字
                if(window.pinyin_dict_notone)
                {
                    // 对于拼音转汉字，我们优先使用pinyin_dict_notone字典文件
                    // 因为这个字典文件不包含生僻字，且已按照汉字使用频率排序
                    dict.py2hz = pinyin_dict_notone; // 拼音转汉字
                }
                else
                {
                    // 将字典文件解析成拼音->汉字的结构
                    // 与先分割后逐个去掉声调相比，先一次性全部去掉声调然后再分割速度至少快了3倍，前者大约需要120毫秒，后者大约只需要30毫秒（Chrome下）
                    var notone = pinyinUtil.removeTone(pinyin_dict_withtone).split(',');
                    var py2hz = {}, py, hz;
                    for(var i=0, len = notone.length; i<len; i++)
                    {
                        hz = String.fromCharCode(i + 19968); // 汉字
                        py = notone[i].split(' '); // 去掉了声调的拼音数组
                        for(var j=0; j<py.length; j++)
                        {
                            py2hz[py[j]] = (py2hz[py[j]] || '') + hz;
                        }
                    }
                    dict.py2hz = py2hz;
                }
            }
        }
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)
  }
}
353439
protected void writeDate(Date date, CharBuf buffer) {
        SimpleDateFormat formatter = new SimpleDateFormat(dateFormat, dateLocale);
        formatter.setTimeZone(timezone);
        buffer.addQuoted(formatter.format(date));
    }
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();
  }
1015040
function addFile( file ) {
            var $li = $( '<li id="' + file.id + '">' +
                    '<p class="title">' + file.name + '</p>' +
                    '<p class="imgWrap"></p>'+
                    '<p class="progress"><span></span></p>' +
                    '</li>' ),

                $btns = $('<div class="file-panel">' +
                    '<span class="cancel">删除</span>' +
                    '<span class="rotateRight">向右旋转</span>' +
                    '<span class="rotateLeft">向左旋转</span></div>').appendTo( $li ),
                $prgress = $li.find('p.progress span'),
                $wrap = $li.find( 'p.imgWrap' ),
                $info = $('<p class="error"></p>'),

                showError = function( code ) {
                    switch( code ) {
                        case 'exceed_size':
                            text = '文件大小超出';
                            break;

                        default:
                            text = '上传失败，请重试';
                            break;
                    }

                    $info.text( text ).appendTo( $li );
                };

            if ( file.getStatus() === 'invalid' ) {
                showError( file.statusText );
            } else {
                // @todo lazyload
                $wrap.text( '预览中' );
                uploader.makeThumb( file, function( error, src ) {
                    if ( error ) {
                        $wrap.text( '不能预览' );
                        return;
                    }

                    var img = $('<img src="'+src+'">');
                    $wrap.empty().append( img );
                }, thumbnailWidth, thumbnailHeight );

                percentages[ file.id ] = [ file.size, 0 ];
                file.ratation = 0;
            }

            file.on('statuschange', function( cur, prev ) {
                if ( prev === 'progress' ) {
                    $prgress.hide().width(0);
                } else if ( prev === 'queued' ) {
                    $li.off( 'mouseenter mouseleave' );
                    $btns.remove();
                }

                // 成功
                if ( cur === 'error' || cur === 'invalid' ) {
                    showError( file.statusText );
                    percentages[ file.id ][ 1 ] = 1;
                } else if ( cur === 'queued' ) {
                    percentages[ file.id ][ 1 ] = 0;
                } else if ( cur === 'progress' ) {
                    $info.remove();
                    $prgress.css('display', 'block');
                }

                $li.removeClass( 'state-' + prev ).addClass( 'state-' + cur );
            });

            $li.on( 'mouseenter', function() {
                $btns.stop().animate({height: 30});
            });

            $li.on( 'mouseleave', function() {
                $btns.stop().animate({height: 0});
            });

            $btns.on( 'click', 'span', function() {
                var index = $(this).index(),
                    deg;

                switch ( index ) {
                    case 0:
                        uploader.removeFile( file );
                        return;

                    case 1:
                        file.ratation += 90;
                        break;

                    case 2:
                        file.ratation -= 90;
                        break;
                }

                // -webkit-transform: rotate(90deg);
                index && (deg = 'rotate(' + file.ratation + 'deg)', $wrap.css({
                    '-webkit-transform': deg,
                    '-mos-transform': deg,
                    '-o-transform': deg,
                    'transform': deg
                }));
            });

            $li.appendTo( $queue );
        }
269415
def __loaddate():
        ''' 
        '''
        csv_path = os.path.join(os.path.dirname(__file__), 'opendate.csv')
        with open(csv_path) as csv_file:
            csv_data = csv.reader(csv_file)
            result = {}
            result['close'] = []
            result['open'] = []
            for i in csv_data:
                if i[1] == '0':  # 0 = 休市
                    result['close'].append(datetime.strptime(i[0],
                                                             '%Y/%m/%d').date())
                elif i[1] == '1':  # 1 = 開市
                    result['open'].append(datetime.strptime(i[0],
                                                            '%Y/%m/%d').date())
                else:
                    pass
            return result
149607
function (options, callback) {

			fs.stat(options.file_path, function (err, stats) {

				if (err) {
					callback(err);
				}
				else {
					var local_date = new Date(stats.mtime).getTime();
					var server_date = new Date(options.server_date).getTime();

					if (options.compare_date === 'newer') {
						callback(null, local_date > server_date);
					}
					else {
						callback(null, local_date < server_date);
					}
				}
			});
		}
416101
function (source, packToPath, fileType) {
        /*存放文件内容*/
        var packToFile,
            /*这个打包的文件是否已经存在,如果已经存在需要在fis编译组件里warming*/
            packToExist = false,
            /*内容*/
            content = '';
        /*packTo不存在则退出*/
        if (!packToPath) {
            return
        }
        /*转化成fis的file格式*/
        packToFile = wrapFile(packToPath);
        /*判断pack的文件是否存在*/
        packToExist = fis.util.isFile(packToFile.fullname);
        /*如果packTo的文件存在，给用户一个提醒*/
        if (packToExist) {
            fis.log.warning(packToFile.fullname + 'has exists. Check your result,please!');
        }
        /*对资源列表进行挨个处理，将文件合并*/
        if(fileType == 'json') {
            var jsonFile = new JSONFile();
            source.forEach(function (file){
                jsonFile.add(file._content);
            });
            content = jsonFile.content();
        }
        else {
            source.forEach(function (file){
                content += file._content;
            });
        }
        /*将内容设置进入pack的文件夹*/
        packToFile.setContent(content);
        ret.pkg[packToPath] = packToFile;
    }
275128
function walk(dir, doneFn) {
    fs.readdir(dir, (err, list) => {
      if (err) return doneFn(err);

      list.forEach((file) => {
        // img图片不部署，使用七牛云单独存储
        if (path.basename(dir) === options.outputDir && file === 'img') return;

        file = path.resolve(dir, file);

        fs.stat(file, (eror, stats) => {
          if (eror) return doneFn(err);

          const isFile = stats.isFile(); // 是文件
          const isDir = stats.isDirectory(); // 是文件夹

          if (isFile) {
            return doneFn(null, file);
          }
          if (isDir) {
            walk(file, doneFn); // 递归，如果是文件夹，就继续遍历该文件夹下面的文件
          }
        });
      });
    });
  }
1246319
function(filesArr) {
		// 读取package.json，将里面内容生成头信息
		var data = fs.readFileSync('./package.json', 'utf8');
		var packageObj = JSON.parse( data );

		var headerStr = '/** \r\n';
			headerStr += ' * ' + packageObj.name + ' v' + packageObj.version + '\r\n';
			headerStr += ' * ' + packageObj.description + '\r\n';
			headerStr += ' * author : ' + packageObj.author + '\r\n';
			headerStr += ' * homepage : ' + packageObj.homepage + '\r\n';
			headerStr += ' * bugs : ' + packageObj.bugs.url + '\r\n';
			headerStr += ' **/ \r\n';


		for (var i = 0; i < filesArr.length; i++){
			var filePath = filesArr[i]
			var data = fs.readFileSync(filePath, 'utf8');
			data = headerStr  + data;
			fs.writeFileSync(filePath, data);
		}
	}