设置以上文时间为基准的时间偏移计算

add by 曹零
163342
public void norm_setBaseRelated() {
        String[] time_grid = new String[6];
        time_grid = timeBaseText.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();

        //year, month, day, hour, min, second
        boolean[] flag = {false, false, false, 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);
        }

        /////////////////////新支持各类之前/之后 //////	//added by zhu
        rule = "\\d+(?=小时[以之]?前)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[4] = true;
            int hour = Integer.parseInt(match.group());
            long ms = calendar.getTime().getTime() - hour * 3600 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "\\d+(?=小时[以之]?后)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[4] = true;
            int hour = Integer.parseInt(match.group());
            long ms = calendar.getTime().getTime() + hour * 3600 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "半个?小时[以之]?前";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[4] = true;
            long ms = calendar.getTime().getTime() - 1800 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "半个?小时[以之]?后";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[4] = true;
            long ms = calendar.getTime().getTime() + 1800 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "\\d+(?=刻钟[以之]?前)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[4] = true;
            int q = Integer.parseInt(match.group());
            long ms = calendar.getTime().getTime() - q * 15 * 60 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "\\d+(?=刻钟[以之]?后)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[4] = true;
            int q = Integer.parseInt(match.group());
            long ms = calendar.getTime().getTime() + q * 15 * 60 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "\\d+(?=分钟?[以之]?前)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[4] = true;
            int min = Integer.parseInt(match.group());
            long ms = calendar.getTime().getTime() - min * 60 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "\\d+(?=分钟?[以之]?后)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[4] = true;
            int min = Integer.parseInt(match.group());
            long ms = calendar.getTime().getTime() + min * 60 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "半分钟?[以之]?前";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[4] = true;
            long ms = calendar.getTime().getTime() - 30 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "半分钟?[以之]?后";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[4] = true;
            long ms = calendar.getTime().getTime() + 30 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "\\d+(?=秒钟?[以之]?前)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[5] = true;
            int sec = Integer.parseInt(match.group());
            long ms = calendar.getTime().getTime() - sec * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "\\d+(?=秒钟?[以之]?后)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[5] = true;
            int sec = Integer.parseInt(match.group());
            long ms = calendar.getTime().getTime() + sec * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "半秒钟?[以之]?前";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[5] = true;
            long ms = calendar.getTime().getTime() - 500;
            calendar.setTimeInMillis(ms);
        }

        rule = "半秒钟?[以之]?后";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[5] = true;
            long ms = calendar.getTime().getTime() + 500;
            calendar.setTimeInMillis(ms);
        }

        rule = "(\\d+)((周|星期)?[以之]?后)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            int week = Integer.parseInt(match.group(1));
            long ms = calendar.getTime().getTime() + week * 7 * 24 * 3600 * 1000;
            calendar.setTimeInMillis(ms);
        }

        rule = "(\\d+)((周|星期)?[以之]?前)";
        pattern = Pattern.compile(rule);
        match = pattern.matcher(Time_Expression);
        if (match.find()) {
            flag[2] = true;
            String weekText = match.group(1);
            int week = Integer.parseInt(match.group(1));
            long ms = calendar.getTime().getTime() - week * 7 * 24 * 3600 * 1000;
            calendar.setTimeInMillis(ms);
        }
        ///////////////////////////////////////

        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] || flag[3] || flag[4] || flag[5]) {
            _tp.tunit[0] = Integer.parseInt(time_fin[0]);
        }
        if (flag[1] || flag[2] || flag[3] || flag[4] || flag[5]) {
            _tp.tunit[1] = Integer.parseInt(time_fin[1]);
        }
        if (flag[2] || flag[3] || flag[4] || flag[5]) {
            _tp.tunit[2] = Integer.parseInt(time_fin[2]);
        }
        if (flag[3] || flag[4] || flag[5]) {
            _tp.tunit[3] = Integer.parseInt(time_fin[3]);
        }
        if (flag[4] || flag[5]) {
            _tp.tunit[4] = Integer.parseInt(time_fin[4]);
        }
        if (flag[5]) {
            _tp.tunit[5] = Integer.parseInt(time_fin[5]);
        }
    }
375086
def add(self, src):
        

        checksum = get_checksum(src)

        filename = self.get_filename(checksum)

        if not filename:

            new_name = self._get_new_name()
            new_realpath = self._storage_dir + '/' + new_name

            os.makedirs(os.path.split(new_realpath)[0], exist_ok=True)

            shutil.copyfile(src, new_realpath)

            self._log[new_name] = {
                'checksum': checksum,
                'mtime': os.path.getmtime(new_realpath),
                'size': os.path.getsize(new_realpath)
            }

            self.write_log()
        return checksum
151389
public T addPyFile(String file) {
    checkNotNull(file, "file");
    builder.pyFiles.add(file);
    return self();
  }
1158873
def add(self, outputfilename, outputtemplate, inputfilename=None, inputtemplate=None):
        """"""
        if isinstance(outputtemplate,OutputTemplate):
            outputtemplate = outputtemplate.id
        if isinstance(inputtemplate,InputTemplate):
            inputtemplate = inputtemplate.id
        if outputfilename in self:
            outputtemplate, inputfiles = self[outputfilename]
            if inputfilename and inputtemplate:
                inputfiles[inputfilename] = inputtemplate
        else:
            if inputfilename and inputtemplate:
                self[outputfilename] = (outputtemplate, {inputfilename: inputtemplate})
            else:
                self[outputfilename] = (outputtemplate, {})
759366
private void addFile(File root, File file, String prefix, ZipOutputStream zos) throws IOException {
        FileInputStream fis = new FileInputStream(file);
        ZipEntry jarEntry = new ZipEntry(prefix + normalizePath(root, file));
        zos.putNextEntry(jarEntry);
        StreamUtils.copyStream(fis, zos, false);
        fis.close();
    }
819319
def _add(self, lines):
        '''

        '''
        lines = self._setup('ADD', lines)

        for line in lines:
            values = line.split(" ")
            frompath = values.pop(0)

            # Custom parsing for frompath

            # If it's a web address, add to install routine to get
            if frompath.startswith('http'):
                for topath in values:
                    self._parse_http(frompath, topath)

            # Add the file, and decompress in install
            elif re.search("[.](gz|gzip|bz2|xz)$", frompath.strip()):
                for topath in values:
                    self._parse_archive(frompath, topath)

            # Just add the files
            else:
                for topath in values:
                    self._add_files(frompath, topath)
1241329
public void addUploadFile(HttpServletRequest request,
                            UploadFile uploadFile) {
    if (uploadFile == null)
      return;
    try{
      HttpSession session = request.getSession(true);
      Collection uploadList = (Collection)session.getAttribute(PIC_NAME_PACKAGE);
      if (uploadList == null) {
        uploadList = new ArrayList();
        session.setAttribute(PIC_NAME_PACKAGE, uploadList);
      }
      uploadList.add(uploadFile);
      uploadFile.setTempId(Integer.toString(uploadList.size() - 1)); //临时给予id
    }catch(Exception ex){
      Debug.logError("[JdonFramework]addUploadFile error:" + ex, module);
    }

  }
552404
def add_file(self, name="", hashalg="", hash="", comClasses=None, 
                 typelibs=None, comInterfaceProxyStubs=None, 
                 windowClasses=None):
        
        self.files.append(File(name, hashalg, hash, comClasses, 
                          typelibs, comInterfaceProxyStubs, windowClasses))
720034
private function addFile(array &$files, string $fieldName, string $filename, string $tmpPath, string $mimeType, bool $err): void
    {
        $data = [
            'type' => $mimeType ?: 'application/octet-stream',
            'name' => $filename,
            'tmp_name' => $tmpPath,
            'error' => $err ? UPLOAD_ERR_CANT_WRITE : UPLOAD_ERR_OK,
            'size' => filesize($tmpPath),
        ];

        $parts = preg_split('|(\[[^\]]*\])|', $fieldName, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
        $count = count($parts);
        if (1 === $count) {
            $files[$fieldName] = $data;
        } else {
            $current = &$files;
            foreach ($parts as $i => $part) {
                if ($part === '[]') {
                    $current[] = $data;
                    continue;
                }

                $trimmedMatch = trim($part, '[]');
                if ($i === $count -1) {
                    $current[$trimmedMatch] = $data;
                } else {
                    $current = &$current[$trimmedMatch];
                }
            }
        }
    }
1148868
async function add(files) {
	const shell = await execa('git', ['add', '--ignore-errors'].concat(files), {reject: false});
	debug('add file to git index', shell);
}
1312905
public boolean add(String fileName) {
      writeLock.lock();
      try {
         return filenames.add(fileName);
      } finally {
         writeLock.unlock();
      }
   }
1324931
private static void addFile(File file, String path, ZipOutputStream out) throws UtilException {
		BufferedInputStream in = null;
		try {
			in = FileUtil.getInputStream(file);
			addFile(in, path, out);
		} finally {
			IoUtil.close(in);
		}
	}
162790
def add_files(session, imagedir, verbose):
  """"""

  def add_file(session, basename, userid, shotid, sessionid):
    """Parse a single filename and add it to the list."""
    session.add(File(userid, basename, sessionid, shotid))

  filenames = os.listdir(imagedir)
  for filename in filenames:
    basename, extension = os.path.splitext(filename)
    if extension == db_file_extension:
      if verbose>1: print("  Adding file '%s'..." % (basename))
      parts = string.split(basename, "_")
      ctype = parts[0]
      shotid = int(parts[2])
      userid = ctype + '_%d' % int(parts[1])
      if parts[0] == "Impostor":
        sessionid = 3
      elif parts[0] == "Genuine" and shotid <= 6:
        sessionid = 1
      elif parts[0] == "Genuine" and shotid > 6:
        sessionid = 2
        shotid = shotid - 6
      add_file(session, basename, userid, shotid, sessionid)
260331
function addFile(filename) {
        if (ignoredPaths.contains(filename)) {
            return;
        }
        filename = fs.realpathSync(filename);
        if (added[filename]) {
            return;
        }
        files.push(filename);
        added[filename] = true;
    }
1231549
public void addByeCommand() {
        StringBuilder buf = new StringBuilder();
        buf.append("(bye)");
        fifo.add(fifo.size(), buf.toString());
    }
515853
public void addFile(String filename, String filePath) {
        int pathIndex = filePathList.indexOf(filePath);
        if (pathIndex == -1) {
            fileNameList.add(filename);
            filePathList.add(filePath);
        }
    }
1063997
def add_extension(self, extension):
        
        if extension:
            extension_to_add = os.path.abspath(os.path.expanduser(extension))
            if os.path.exists(extension_to_add):
                self._extension_files.append(extension_to_add)
            else:
                raise IOError("Path to the extension doesn't exist")
        else:
            raise ValueError("argument can not be null")