Jump to content
Sign in to follow this  
Khautekier

DateAdd function is not working correct

Recommended Posts

Hi all,

i wrote some code to start an application every nn minutes.

if the initial time is set to 01 minute. the code works fine and change from 2006/12/05 23:00:01 to

2006/12/06 00:00:01

if the initial time is set to 00 minute. the DateAdd function Starts incrementing the days instead of the hours

-from 2006/12/05 22:00:00 to 2006/12/05 23:00:00 ( :evil: )

-from 2006/12/05 23:00:00 to 2006/12/06 23:00:00 ( ;) )

-from 2006/12/06 23:00:00 to 2006/12/07 23:00:00 :lmao:

Is this a bug with _dateAdd of could anybody tell me what i am doing wrong?

#include <Constants.au3>
#include <GUIConstants.au3>
#include <Date.au3>

$Sample_Interval = 60
$Next_sample_time = "2006/12/05 19:00:01"

while 1
    $Next_sample_time =  _DateAdd( 'n',$Sample_Interval, $Next_sample_time)
    $Answer = MsgBox(1,"Correct DateAdd",$Next_sample_time)
    if $Answer = 2 then ExitLoop
WEnd    

$Sample_Interval = 60
$Next_sample_time = "2006/12/05 19:00:00"

while 1
    $Next_sample_time =  _DateAdd( 'n',$Sample_Interval, $Next_sample_time)
    $Answer = MsgBox(1,"Wrong DateAdd",$Next_sample_time)
    
    if $Answer = 2 then ExitLoop
WEnd

Share this post


Link to post
Share on other sites

Is this a bug with _dateAdd of could anybody tell me what i am doing wrong?

as far as I can see there are bugs in _DateAdd and _TicksToTime (in Date.au3).

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

as far as I can see there are bugs in _DateAdd and _TicksToTime (in Date.au3).

Cheers

Kurt

_TicksToTime() didn't handle Ticks=0 properly .

Changed it in attached version of Date.au3.

See if that fixes you issues and let me know...

I will commit this change for the next version.

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

_TicksToTime() didn't handle Ticks=0 properly .

Changed it in attached version of Date.au3.

See if that fixes you issues and let me know...

I will commit this change for the next version.

;):lmao: See my post: http://www.autoitscript.com/forum/index.php?showtopic=37371

I have a different fix, but both of them do work! Yours is more generic.

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

;):lmao: See my post: http://www.autoitscript.com/forum/index.php?showtopic=37371

I have a different fix, but both of them do work! Yours is more generic.

Cheers

Kurt

I think the _TicksToTime() mneeds the fix not _DateAdd() whicg depents on _TicksToTime .

I will Update the Bug thread ....

Thanks

:evil:


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I think the _TicksToTime() mneeds the fix not _DateAdd() whicg depents on _TicksToTime .

I will Update the Bug thread ....

Thanks

;)

well, actually it does not matter what you fix, because _TicksToTime is only used by _DateAdd(). However I agree with your fix. It's the better place to fix this problem.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

well, actually it does not matter what you fix, because _TicksToTime is only used by _DateAdd(). However I agree with your fix. It's the better place to fix this problem.

Cheers

Kurt

Partially true...

_TicksToTime () is a published UDF and should return a correct value in case the Ticks is 0, thats why I fixed it in the _TicksToTime function ...

Thanks for your help on this one .

;)


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Partially true...

_TicksToTime () is a published UDF and should return a correct value in case the Ticks is 0, thats why I fixed it in the _TicksToTime function ...

Thanks for your help on this one .

;)

yep, you're right. Did'nt know that _TickToTime() is a published UDF.....

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...