Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Server Time
Message
From
12/04/2004 11:27:44
 
 
To
12/04/2004 11:19:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00891634
Message ID:
00894065
Views:
15
Just a few comments:

a. variable cRutaServidor contains the path in server where to write a file.

b. Then we take the date and time, that is asigned by server, when the file was created.

c. sorry for this re-reply



>Ryan, next code is working fine for me.
>
>Enrique
>
>
>#DEFINE MSG_01 '          ¿Desea sicronizar su reloj con el reloj del servidor?'
>#DEFINE MSG_02 'La hora del servidor y la hora local son diferentes...'
>#DEFINE MSG_03 'No es posible crear el archivo en el servidor, inténtelo otra vez'
>#DEFINE MSG_04 '(Reloj en Servidor  - Reloj en Máquina Local) = '
>#DEFINE MSG_05 ' minutos de diferencia'
>
>cRutaServidor = "\\srvig\mantto\" && WindowsNT installed in server
>oSincReloj = CreateObject("SincReloj")
>= oSincReloj.SincroReloj(cRutaServidor)
>
>Define Class SincReloj as custom
>
>	Function SincroReloj(cRutaServidor)
>		llSincro = .F.
>		cNombre = sys(2015)+".txt"
>		cArchivoReloj = cRutaServidor + cNombre
>		if file(cArchivoReloj)  && existe ya el archivo?
>			= messagebox(MSG_03)
>		else
>			nTxtFile = fcreate(cArchivoReloj)
>			ltLocal = datetime()
>		endif
>		if nTxtFile < 0     && Check for error opening file
>			= messagebox(MSG_03)
>			return
>		endif
>		=fclose(nTxtFile )     && Close file
>
>		oMyFiler = createobject('Filer.FileUtil')
>		oMyFiler.SearchPath = cRutaServidor && Default directory
>		oMyFiler.FileExpression = cNombre && Text file search
>		oMyFiler.find(0)
>		nFHsrv = oMyFiler.files.item(1).LastWriteTime && file - date
>		oMyFiler.files.item(1).delete && Delete file
>		
>		dFechaSrv = date(1899,12,30) + int(nFHsrv)
>		nFrac = nFHsrv - int(nFHsrv)
>		nHora = int(nFrac*24)
>		nMin = int(nFrac*1440) - 60*int(nFrac*24)
>		nSeg = int(nFrac*86400) - 60*int(nFrac*1440)
>
>		ltSrv = DateTime(year(dFechaSrv), ;
>			month(dFechaSrv), ;
>			day(dFechaSrv), ;
>			nHora, nMin, nSeg)
>
>		nDif = int((ltSrv - ltLocal)/60)
>		If nDif # 0
>			cDiferencia =  MSG_04 + allt(str(nDif)) + MSG_05 + chr(13) +chr(13)
>			if messagebox(cDiferencia +MSG_01, 4+64, MSG_02) = 6
>				= This.WriteLocalTime(ltSrv)
>				llSincro = .T.
>			endif
>		else
>			= messagebox('Su reloj está sicronizado con el servidor en \\srvig', 'Reloj sincronizado')
>		endif
>		Return llSincro && .T. cuando se realizó la sincronización
>	EndFunc
>
>	FUNCTION WriteLocalTime(ltDateTime)
>		IF TYPE("ltDateTime") # "T"
>			RETURN .F.
>		ENDIF
>		LOCAL lcCadena
>
>		With This
>		lcCadena = ._10to256(YEAR(ltDateTime),2) + ;
>					._10to256(MONTH(ltDateTime),2) + ;
>					._10to256(DOW(ltDateTime),2) + ;
>					._10to256(DAY(ltDateTime),2) + ;
>					._10to256(HOUR(ltDateTime),2) + ;
>					._10to256(MINUTE(ltDateTime),2) + ;
>					._10to256(SEC(ltDateTime),2) + ;
>					._10to256(000,2) + SPACE(24)
>		EndWith
>
>		DECLARE SetLocalTime IN win32api ;
>			STRING lcCadena
>
>		RETURN SetLocalTime(lcCadena)
>	ENDFUNC
>
>	FUNCTION _10to256(lnNumero, lnCant)
>		LOCAL lcRetorno, lnAscii
>
>		lcRetorno=''
>		DO WHILE lnNumero >= 256
>			lnAscii=MOD(lnNumero,256)
>			lcRetorno=lcRetorno + CHR(lnAscii)
>			lnNumero=INT(lnNumero / 256)
>		ENDDO
>		lnAscii=lnNumero
>		lcRetorno=lcRetorno + CHR(lnAscii)
>		RETURN PADR(lcRetorno, lnCant, CHR(0))
>	ENDFUNC
>
>EndDefine
>
Previous
Reply
Map
View

Click here to load this message in the networking platform