Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么_DateDiff()返回0?_Date_Time_Autoit_Time Estimation - Fatal编程技术网

为什么_DateDiff()返回0?

为什么_DateDiff()返回0?,date,time,autoit,time-estimation,Date,Time,Autoit,Time Estimation,我的AutoIt脚本应该通过说进程将在下午3:18:24完成来预测进程何时完成。但事实并非如此。它采用以下输入值: 开始时间 起始百分比 当前时间 当前百分比 它显示: "The extraction will be complete at 0". 我把这个问题孤立起来。我认为第一个参数是n,表示分钟差。但当我传递下两个参数(相隔60分钟的日期值)时,它返回0。代码如下: GUICreate("Completion Time Predictor", 300, 300) ;Here I ente

我的AutoIt脚本应该通过说
进程将在下午3:18:24完成来预测进程何时完成。但事实并非如此。它采用以下输入值:

  • 开始时间
  • 起始百分比
  • 当前时间
  • 当前百分比
  • 它显示:

    "The extraction will be complete at 0".
    
    我把这个问题孤立起来。我认为第一个参数是
    n
    ,表示分钟差。但当我传递下两个参数(相隔60分钟的日期值)时,它返回
    0
    。代码如下:

    GUICreate("Completion Time Predictor", 300, 300)
    ;Here I enter the starting time and percentage
    GUICtrlCreateLabel("Enter the start time:", 10, 10, 270, 29)
    $StartTime = GUICtrlCreateDate("", 10, 40, 270, 21, $DTS_TIMEFORMAT)
    GUICtrlCreateLabel("Enter the start percentage:", 10, 70, 270, 29)
    Local $StartPercent = GUICtrlCreateInput("", 10, 100, 270, 21)
    ;Here I enter the current time and percentage
    GUICtrlCreateLabel("Enter the current time:", 10, 130, 270, 29)
    $CurrentTime = GUICtrlCreateDate("", 10, 160, 270, 21, $DTS_TIMEFORMAT)
    GUICtrlCreateLabel("Enter the current percentage:", 10, 190, 270, 29)
    Local $CurrentPercent = GUICtrlCreateInput("", 10, 220, 270, 21)
    Local $CTRL_a = GUICtrlCreateButton("Calculate", 10, 260, 280, 21)
    GUISetState()
    Local $msg
    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $CTRL_a
                $PercentChange = GUICtrlRead($CurrentPercent) - GUICtrlRead($StartPercent)
                ;This seems to be where everything is going wrong
                $ChangePerMinute = $PercentChange / _DateDiff('n', GUICtrlRead($StartTime), GUICtrlRead($CurrentTime))
                $MinutesRemaining = (100 - GUICtrlRead($CurrentPercent)) / $ChangePerMinute
                $EndTime = _DateAdd('n', $MinutesRemaining, GUICtrlRead($CurrentTime))
                MsgBox($MB_OK, "Predicted Completion Time:", "The extraction will be complete at  " & $EndTime)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
    

    我不知道你在做什么,但也许这能帮你找到问题所在

    #include <Date.au3>
    #include <DateTimeConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <MsgBoxConstants.au3>
    GUICreate("Completion Time Predictor", 300, 300)
    ;Here I enter the starting time and percentage
    GUICtrlCreateLabel("Enter the start time:", 10, 10, 270, 29)
    $StartTime = GUICtrlCreateDate("", 10, 40, 270, 21, $DTS_TIMEFORMAT)
    GUICtrlCreateLabel("Enter the start percentage:", 10, 70, 270, 29)
    Local $StartPercent = GUICtrlCreateInput("0", 10, 100, 270, 21)
    ;Here I enter the current time and percentage
    GUICtrlCreateLabel("Enter the current time:", 10, 130, 270, 29)
    $CurrentTime = GUICtrlCreateDate("", 10, 160, 270, 21, $DTS_TIMEFORMAT)
    GUICtrlSetData(-1, _NowCalcDate() & ' ' & @HOUR + 1 & ":" & @MIN & ':' & @SEC)
    GUICtrlCreateLabel("Enter the current percentage:", 10, 190, 270, 29)
    Local $CurrentPercent = GUICtrlCreateInput("10", 10, 220, 270, 21)
    Local $CTRL_a = GUICtrlCreateButton("Calculate", 10, 260, 280, 21)
    GUISetState()
    Local $msg
    
    Do
        $msg = GUIGetMsg()
        Select
            Case $msg = $CTRL_a
                ConsoleWrite(_NowCalcDate() & ' ' & GUICtrlRead($StartTime) & " " & _NowCalcDate() & ' ' & GUICtrlRead($CurrentTime) & @CRLF)
                $PercentChange = GUICtrlRead($CurrentPercent) - GUICtrlRead($StartPercent)
                ConsoleWrite("% Change: " & $PercentChange & @CRLF)
                ;This seems to be where everything is going wrong
                $diff_min = _DateDiff('n', _NowCalcDate() & ' ' & GUICtrlRead($StartTime), _NowCalcDate() & ' ' & GUICtrlRead($CurrentTime))
                ConsoleWrite("Diff in Min: " & $diff_min & @CRLF)
                $ChangePerMinute = $PercentChange / $diff_min
                ConsoleWrite("Change / min : " & $ChangePerMinute & @CRLF)
                $MinutesRemaining = (100 - GUICtrlRead($CurrentPercent)) / $ChangePerMinute
                ConsoleWrite("MinutesRemaining : " & " " & $MinutesRemaining & @CRLF)
                $EndTime = _DateAdd('n', $MinutesRemaining, _NowCalcDate() & ' ' & GUICtrlRead($CurrentTime))
                MsgBox($MB_OK, "Predicted Completion Time:", "The extraction will be complete at  " & $EndTime)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
    
    #包括
    #包括
    #包括
    #包括
    GUICreate(“完成时间预测器”,300300)
    ;我在这里输入开始时间和百分比
    GUICtrlCreateLabel(“输入开始时间:”、10、10、270、29)
    $StartTime=GUICtrlCreateDate(“、10、40、270、21、$DTS_TIMEFORMAT)
    GUICtrlCreateLabel(“输入开始百分比:”、10、70、270、29)
    本地$StartPercent=GUICtrlCreateInput(“0”、1010027021)
    ;我在这里输入当前时间和百分比
    GUICtrlCreateLabel(“输入当前时间:”、10、130、270、29)
    $CurrentTime=GUICtrlCreateDate(“、10、160、270、21、$DTS_时间格式)
    GUICtrlSetData(-1,_nowcaldate()&''&@HOUR+1&'':''&@MIN&':'&@SEC)
    GUICtrlCreateLabel(“输入当前百分比:”、10、190、270、29)
    本地$CurrentPercent=GUICtrlCreateInput(“10”、10、220、270、21)
    本地$CTRL_a=GUICtrlCreateButton(“计算”,10260280,21)
    GUISetState()
    本地$msg
    做
    $msg=GUIGetMsg()
    挑选
    案例$msg=$CTRL\U a
    控制台写入(_NowCalcDate()&''和GUICtrlRead($StartTime)和“”&_NowCalcDate()&''和GUICtrlRead($CurrentTime)和@CRLF)
    $PercentChange=GUICtrlRead($CurrentPercent)-GUICtrlRead($StartPercent)
    控制台写入(“%Change:&$PercentChange&@CRLF)
    ;这似乎是一切都出错的地方
    $diff_min=\u DateDiff('n','u NowCalcDate()&''和GUICtrlRead($StartTime),'u NowCalcDate()&''和GUICtrlRead($CurrentTime))
    控制台写入(“最小差异:&$Diff_Min&@CRLF)
    $ChangePerMinute=$PercentChange/$diff_min
    控制台写入(“更改/分钟:&$ChangePerMinute&@CRLF)
    $MinutesLeving=(100-GUICtrlRead($CurrentPercent))/$ChangePerMinute
    控制台写入(“剩余分钟数:&“&”和$minuteslaining&@CRLF)
    $EndTime=_DateAdd('n',$minutesrainding,_nowcaldate()&''和GUICtrlRead($CurrentTime))
    MsgBox($MB_OK,“预计完成时间:”,“提取将在“&$EndTime完成”)
    结束选择
    直到$msg=$GUI\u事件\u关闭
    
    。根据定义,$sStartDate和$sEndDate参数需要采用“YYYY/MM/DD[HH:MM:SS]”格式,这意味着它们需要采用“YYYY/MM/DD”格式的日期或“YYYY/MM/DD HH:MM:SS”格式的日期和时间,但您只使用了时间。因此,我需要在yyyyy/MM/DD格式中添加一个日期。你能给我一些建议,告诉我怎么做吗?我尝试将当前系统日期与时间值连接起来,但没有成功。通过用旧百分比减去当前百分比,可以得到所谓的百分比速度,它可以是1%/秒或其他任何值,通过该值,您可以确定达到100%所需的时间,例如1%/秒意味着它将在100秒或00:01:40内完成。