| View previous topic :: View next topic |
| Author |
Message |
harrys Newbie

Joined: 25 Feb 2007 Posts: 22
|
Posted: Sun Feb 25, 2007 9:14 pm Post subject: set sys time? |
|
|
long time since i been here...still on vds 4.5
can anyone give me pointers in setting system time?
thanks,
george |
|
| Back to top |
|
 |
harrys Newbie

Joined: 25 Feb 2007 Posts: 22
|
Posted: Mon Feb 26, 2007 6:20 am Post subject: |
|
|
found the timedate.dll
however, it sets the milli sec's
but you can't get them from a NTP at least with the ipp.dll
so the seconds arn't exactly right ...suggestions?
| Code: |
REM GET NTP & SET SYSTEM TIME
EXTERNAL VDSIPP.DLL,DEMO
EXTERNAL TIMEDATE.DLL
REM GET THE TIME
INTERNET NTP,CREATE,1
INTERNET NTP,THREADS,1,OFF
INTERNET NTP,TIMEOUT,1,10000
REM INTERNET NTP,GETTIME,1,NIST1-SJ.WITIME.NET,37,123
INTERNET NTP,GETTIME,1,NIST1.SYMMETRICOM.COM,37
%A = @INTERNET(NTP,DATETIME,1)
INTERNET NTP,DESTROY,1
REM DONE GETTING TIME
REM CLEANUP
OPTION FIELDSEP," "
PARSE "%H;%M;%%TIMEODAY;%D",%A
OPTION FIELDSEP,"/"
PARSE "%%MONTH;%%DAY;%%YEAR",%H
OPTION FIELDSEP,":"
%M = @TRIM(%M)
PARSE "%%HOUR;%%MINUTE;%%SECOND",%M
%%YEAR = @TRIM(%%YEAR)
REM MAKE THE RIGHT CHOICE AM/PM
IF @EQUAL(PM,%%TIMEODAY)
%%HOUR = @FADD(%%HOUR,12)
ELSE
END
REM CHANGE SYSTEM TIME
%Z=@TIMEDATE(SETNEWDT,20%%YEAR,%%MONTH,%%DAY,%%HOUR,%%MINUTE,%%SECOND,)
EXIT
|
|
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Mon Feb 26, 2007 4:14 pm Post subject: |
|
|
I wouldn't worry about it being up to 1 second out. The time between when vdsipp gets the time via ntp and when timedate.dll sets it has got be at least 1/2 second - so it'll be 1/2 second out anyway. You could always hard code the milliseconds to 500.
Using your code on my PC would attempt to set the year as 202007.
BTW setting the time on my PC (XP Pro using a power user account) with
%Z = @TIMEDATE(SETNEWDT,%%YEAR,%%MONTH,%%DAY,%%HOUR,%%MINUTE,%%SECOND,500)
doesn't work... _________________ cheers
Dave |
|
| Back to top |
|
 |
harrys Newbie

Joined: 25 Feb 2007 Posts: 22
|
Posted: Mon Feb 26, 2007 5:02 pm Post subject: |
|
|
don't know XP still on W98SE
how did you tell the progy was tring to set the date to 202007?
the NTP passes the date as 2/22/07 parsed should be "07"
does XP handle the date different than 98?
it seems to be off by about .3 of a second
ok i guess for a community radio station time fetch & sinc
not that the station automation will/does anounce the seconds when it says the time.
i had the milliseconds HC at 500 but it would set the time
over 1+ second too fast.
| Quote: |
BTW setting the time on my PC (XP Pro using a power user account) with
%Z=@TIMEDATE(SETNEWDT,%%YEAR,%%MONTH,%%DAY,%%HOUR,%%MINUTE,%%SECOND,500)
doesn't work...
|
don't you need permission to set & change settings on XP perhaps that is the issue,?
george[/quote] |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Tue Feb 27, 2007 12:39 am Post subject: |
|
|
XP (or at least my version as it's currently setup) returns the year as 4 digits - i.e. 2007 - so I just added the following quick hack:
| Code: | if @greater(100,%%YEAR)
%%YEAR = @FADD(2000,%%YEAR)
end
%Z = @TIMEDATE(SETNEWDT,%%YEAR,%%MONTH,%%DAY,%%HOUR,%%MINUTE,%%SECOND,500)
|
According to timedate's help file you need the appropriate permissions to set the date/time. I tested it from a Power User account (which should have the necessary permission settings). _________________ cheers
Dave |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Feb 27, 2007 2:23 am Post subject: |
|
|
Did you check the values that your variables for TimeDate.DLL hold?
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Feb 27, 2007 2:28 am Post subject: |
|
|
Perhaps something like this:
| Code: |
external TimeDate.dll
EXTERNAL VDSIPP.DLL,DEMO
%%vdsver = @sysinfo(dsver)
if @equal(@substr(%%vdsver,1),5)
#define function,timedate
#define function,INTERNET
#define command,INTERNET
end
option decimalsep,"."
%%newsep = @timedate(setdecsep,".")
INTERNET NTP,CREATE,1
INTERNET NTP,THREADS,1,OFF
INTERNET NTP,TIMEOUT,1,10000
INTERNET NTP,GETTIME,1,NIST1.SYMMETRICOM.COM,37
%A = @INTERNET(NTP,RAWDATETIME,1)
INTERNET NTP,DESTROY,1
%%YEAR = @datetime(yyyy,%A)
%%MONTH = @datetime(mm,%A)
%%DAY = @datetime(dd,%A)
%%timevalues = @timedate(DecodeTime, %A)
parse "%%HOUR;%%MINUTE;%%SECOND;%%MSEC",%%timevalues
INFO "@TIMEDATE(SETNEWDT,"%%YEAR","%%MONTH","%%DAY","%%HOUR","%%MINUTE","%%SECOND","%%MSEC")"
REM %%setTD = @TIMEDATE(SETNEWDT, %%YEAR, %%MONTH, %%DAY, %%HOUR, %%MINUTE, %%SECOND, %%MSEC)
|
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Tue Feb 27, 2007 2:39 pm Post subject: |
|
|
| Dr. Dread wrote: | | Did you check the values that your variables for TimeDate.DLL hold? |
I did... but I missed spotting that this line in George's code - PARSE "%%MONTH;%%DAY;%%YEAR",%H - was parsing the month as %%DAY and the day as %%MONTH (as it's assuming %H holds a USA style date format - which we don't use here).
Your example code using @datetime() to parse the day and month from the value returned by @INTERNET(NTP,RAWDATETIME,1) worked perfectly.  _________________ cheers
Dave |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|