zoukankan      html  css  js  c++  java
  • 一个简单的工作日计算

    一个简单的工作日计算:

    function getWorkDay(dtBegin:TDateTime;IncDays:Integer):TDateTime;
    const
      days: array[1..7] of string=('7','1','2','3','4', '5','6');
    var
      week1:string;
      x:integer;
      holiday:TStrings;
    begin
      //初始化节假日,
      holiday:=TStringList.Create;
      //TODO:从数据库中取,此为演示
      holiday.Add('2014-10-01');
      holiday.Add('2014-10-02');  //and so on ...
      try
        //日期
        x:=1;
        while (x<=IncDays) do
        begin
          //判断是否周末
          week1:=days[DayOfWeek(dtBegin)];
          //今日周几
          if (week1='6') or (week1='7') or (holiday.IndexOf(FormatDateTime('yyyy-mm-dd',dtBegin))>=0) then
          begin
            dtBegin:=IncDay(dtBegin,1);
            Continue;
          end
          else
          begin
            dtBegin:=IncDay(dtBegin,1);
            x:=x+1;
          end;
        end;
        Result:=dtBegin;
      finally
        holiday.Free;
      end;
    end;
  • 相关阅读:
    UIView添加手势
    UIView常见属性设置汇总
    关于页面传值
    有关segue的简介
    alloc
    如何定义静态方法
    一座小城
    清明
    开通博客
    iOS学习之界面间传值
  • 原文地址:https://www.cnblogs.com/GarfieldTom/p/3974773.html
Copyright © 2011-2022 走看看