Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change system date and time
Message
 
 
À
15/06/2012 15:13:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Divers
Thread ID:
01546116
Message ID:
01546117
Vues:
60
>Hi friends:
>
>I want to change date and/or time wihin VFP. I tried using "RUN (NEWDATE)" but it doesn't work. I tried searching on the web and I found just a few API based funcitons but they haven't worked either. Perhaps any of you knows the magical solution.
>
>Thank you
>
> Hector

First you need to create a system time:
PROCEDURE CreateSystemTime
LPARAMETERS ttTimeStamp
#DEFINE WORD 2
#DEFINE LDWORD 8
IF VARTYPE(ttTimeStamp) # "T"
	ttTimeStamp = DATETIME()
ENDIF
LOCAL	lcResult, ;
		lnYear, ;
		lnMonth, ;
		lnDow, ;
		lnDay, ;
		lnHour, ;
		lnMinute, ;
		lnSec
*
lnYear = YEAR(ttTimeStamp)
lnMonth = MONTH(ttTimeStamp)
lnDow = DOW(ttTimeStamp) - 1
lnDay = DAY(ttTimeStamp)
lnHour = HOUR(ttTimeStamp)
lnMinute = MINUTE(ttTimeStamp)
lnSec = SEC(ttTimeStamp)
*
WITH THIS
	lcResult = .IntegerToString(lnYear, WORD) + ;
				.IntegerToString(lnMonth, WORD) + ;
				.IntegerToString(lnDow, WORD) + ;
				.IntegerToString(lnDay, WORD) + ;
				.IntegerToString(lnHour, WORD) + ;
				.IntegerToString(lnMinute, WORD) + ;
				.IntegerToString(lnSec, WORD) + ;
				.IntegerToString(0, WORD)
ENDWITH
RETURN lcResult
Then you can update the time:
ltDateTime = DATETIME(2000,1,1,12,00,00)
lsSysTime = CreateSystemTime(ltDateTime)
DECLARE INTEGER SetLocalTime IN Kernel32 STRING
SetLocalTime(lsSysTime)
I used to do that after checking the time on the database server and then "syncronize" the time on the local machine.
Christian Isberner
Software Consultant
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform