Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can i get server date and time
Message
De
11/04/2002 10:39:15
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
11/04/2002 10:28:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00643049
Message ID:
00643743
Vues:
34
>Hi Hilmar
>
>This was why we needed this. User's were cheating to enter data they forgot and were no longer allowed to enter.
>
>I found this here. Although I'll never find the original thread #. I hope it helped Jay.
>
>Mike

My users don't cheat - there's no need to, at the moment - but the computer clocks sometimes simply are way off (no fault of the user's fault, except that he doesn't check the time regularly). Sometimes, the computer battery may simply be low.

Here is my function, adapted from your suggestion. I don't use a constant for the server path - this is already the default path for my program.

Hilmar.
**********************************************************************
FUNCTION CheckServerTime
	#DEFINE MAXMINUTESDISCREPANCY 10

	local lcDateFile, lnFileHandle, ldServerTime, ldLocalTime
	lcDateFile = sys(2015) + ".tmp"
	lnFileHandle = fcreate(lcDateFile) && to create a text file on the server.
	fclose(lnFileHandle) && to close it.
	ldServerTime = fdate(lcDateFile, 1) && to read the time of creation.
	ldLocalTime = datetime()
	erase (lcDateFile) && to get rid of the file.
	if abs(ldServerTime - ldLocalTime) > MAXMINUTESDISCREPANCY * 60
		MessageBox("El reloj de su computadora no coincide con el" + CRLF;
			+ "del servidor. Por favor corrija su hora," + CRLF;
			+ "o solicite que se corrija la del servidor." + CRLF;
			+ ttoc(ldServerTime) + " (hora del servidor)" + CRLF;
			+ ttoc(ldLocalTime) + " (hora local)",;
				16, "La hora está mal")
		* ("The time of your computer doesn't match the time on the server.")
		return .F.
	endif
ENDFUNC
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform