Jump to content

Recommended Posts

hi everyone,

i would like ti know is it's possible to add a value to a date, and return the new date

in vbs it's simple :

lngDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _
    + lngLow) / 600000000 - lngAdjust) / 1440
and lngdate is the new date

and i have another question

is auto-it supports unsigned numbers ?

thx

Edited by arcker

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to post
Share on other sites

Try the Function "_DateAdd" found in the "include" folder.

From the help file:

#include <Date.au3>

; Add 5 days to today
$sNewDate = _DateAdd( 'd',5, _NowCalcDate())
MsgBox( 4096, "", "Today + 5 days:" & $sNewDate )

; Subtract 2 weeks from today
$sNewDate = _DateAdd( 'w',-2, _NowCalcDate())
MsgBox( 4096, "", "Today minus 2 weeks: " & $sNewDate )

; Add 15 minutes to current time
$sNewDate = _DateAdd( 'n',15, _NowCalc())
MsgBox( 4096, "", "Current time +15 minutes: " & $sNewDate )

; Calculated eventlogdate which returns second since 1970/01/01 00:00:00 
$sNewDate = _DateAdd( 's',1087497645, "1970/01/01 00:00:00")
MsgBox( 4096, "", "Date: " & $sNewDate )

AutoIt supports the variant datatype. Can contain numbers and strings,

but no "unsigned" data is supported.

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

Link to post
Share on other sites

yes, i've seen this feature, but doesn't support dates under year 1900...

my startpoint must be 01/01/1601 00:00:00

it's the zero point of active directory dates

i've tried to modify the dates.au3 but after it returns negatives values

argh

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to post
Share on other sites

Hi,

Here's a function to emulate vbscript;

"_StampDateAdd($lngHigh,$lngLow,$lngAdjust)"

I assume you can find the high , low values mentioned; here is example using vbscript object!

I don't know if native AutoIt can do it! nor do I know about unsigned; ....

;vbs5.au3

; Here's a function to emulate vbscript;

; I assume you can find the high , low values mentioned; here is example using vbscript object!

; I don't know if native AutoIt can do it!

#include<Date.au3>

MsgBox(0,"Test de vérification","Date "& _

@CRLF&_StampDateAdd(29760000,100,0))

Func _StampDateAdd($lngHigh,$lngLow,$lngAdjust)

$code= "Function Integer8Date(lngHigh,lngLow,lngAdjust)"

$code=$code & @CRLF & "lngDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) + lngLow) / 600000000 - lngAdjust) / 1440"

$code=$code & @CRLF & "Integer8Date = CDate(lngDate)"

;$code=$code & @CRLF & " Account for bug in IADsLargeInteger property methods."

;$code=$code & @CRLF & "If (lngHigh = 0) And (lngLow = 0) Then"

;$code=$code & @CRLF & "lngAdjust = 0"

;$code=$code & @CRLF & "End If"

$code=$code & @CRLF & "end Function"

$vbs = ObjCreate("ScriptControl")

$vbs.language="vbscript"

$vbs.addcode($code)

$retour = $vbs.run("Integer8Date",$lngHigh,$lngLow,$lngAdjust)

$vbs=""

$Year=StringLeft($retour,4)

$Month=StringMid($retour,5,2)

$Day=StringMid($retour,7,2)

$Hour=StringMid($retour,9,2)

$Minute=StringMid($retour,11,2)

$Second=StringMid($retour,13,2)

ConsoleWrite($retour)

$retourstring=$Year&"/"&$Month&"/"&$Day&" "&$Hour&":"&$Minute&":"&$Second

return $retourstring

EndFunc ;==>_StampDateAdd

Best, Randall Edited by randallc
Link to post
Share on other sites

OK,

Here is a way to do the adjustment;

i can't do it in regread in AutoIt; I don't think it accepts those long integers/ varriant options, or else not accurately;

;vbstime6.au3 v _0_2

;vbs5.au3

; Here's a function to emulate vbscript;

; I assume you can find the high , low values mentioned; here is example using vbscript object!

; I don't know if native AutoIt can do it!

#include<Date.au3>

#include<Array.au3>

MsgBox(0,"Test de vérification","Date "& _

@CRLF&_StampDateAdd(29760000,100))

Func _StampDateAdd($lngHigh,$lngLow)

Local $s_Quotes='"'

;""

$code= "Function Integer8Date(lngHigh,lngLow)"

$code = $code & @CRLF & "Dim WshShell, lngBiasKey,lngTZBias"

$code = $code & @CRLF & 'Set WshShell = CreateObject("WScript.Shell")'

$code = $code & @CRLF & "lngBiasKey=WshShell.RegRead(""HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias"")"

$code = $code & @CRLF & "If UCase(TypeName(lngBiasKey)) = ""LONG"" Then"

$code = $code & @CRLF & "lngTZBias = lngBiasKey"

$code = $code & @CRLF & "ElseIf UCase(TypeName(lngBiasKey)) = ""VARIANT()"" Then"

$code = $code & @CRLF & "lngTZBias = 0"

$code = $code & @CRLF & "For k = 0 To UBound(lngBiasKey)"

$code = $code & @CRLF & "lngTZBias = lngTZBias + (lngBiasKey(k) * 256^k)"

$code = $code & @CRLF & "Next"

$code = $code & @CRLF & "End If"

$code=$code & @CRLF & "lngDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) + lngLow) / 600000000 - lngTZBias) / 1440"

$code=$code & @CRLF & "Integer8Date = CDate(lngDate)"

$code=$code & @CRLF & "end Function"

msgbox(0,"",$code)

ConsoleWrite($code)

$vbs = ObjCreate("ScriptControl")

$vbs.language="vbscript"

$vbs.addcode($code)

$retour = $vbs.run("Integer8Date",$lngHigh,$lngLow)

$vbs=""

$Year=StringLeft($retour,4)

$Month=StringMid($retour,5,2)

$Day=StringMid($retour,7,2)

$Hour=StringMid($retour,9,2)

$Minute=StringMid($retour,11,2)

$Second=StringMid($retour,13,2)

ConsoleWrite($retour)

$retourstring=$Year&"/"&$Month&"/"&$Day&" "&$Hour&":"&$Minute&":"&$Second

return $retourstring

EndFunc ;==>_StampDateAdd

Randall
Link to post
Share on other sites
  • Developers

try to change the following in Date.au3:

Line 377: If $asDatePart[1] < 1600 Or $asDatePart[1] > 2999 Then Return (0)

And than this works fine for me:

#include<date.au3>
$Days = _DateDiff('d',"1601/01/01",_NowCalcDate())
ConsoleWrite('@@ Debug(2) : $Days since 01/01/1601= ' & $Days & @lf & '>Error code: ' & @error & @lf);### Debug Console
$Newdate= _DateAdd('d',$Days + 25,"1601/01/01")
ConsoleWrite('@@ Debug(4) : $Newdate = ' & $Newdate & @lf & '>Error code: ' & @error & @lf);### Debug Console

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

Link to post
Share on other sites
  • Developers

@JdeB

why is that line there anyways ?

The idea at the time was to force people to use the 4 digit year and assumption was that nobody would need a date before 1900 anyways...

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

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...