Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum.
Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
[VFP]CLASSE SYSTEMTIME
Information sur la source
Description
Petite classe VFP pour manipulation des SYSTEMTIME de l'API windows en datetime VFP.
Source
- m.lcSt=CREATEOBJECT("SystemTime")
- m.lcSt.GetUTC()
- m.tUTC = m.lcSt.DateTime()
- m.lcSt.GetLocal()
- m.tLocal = m.lcSt.DateTime()
- ? m.tLocal-m.tUtc, "secondes d'écart entre UTC et Local"
- ? (m.tLocal-m.tUtc)/60, "minutes"
- ? (m.tLocal-m.tUtc)/3600, "heures"
-
- DEFINE CLASS SystemTime as custom
- * SYSTEMTIME est composé de 8 WORD (soient 16 octets)
- #define SizeOfSystemTime 8*2
-
- cYear=SPACE(2)
- cMonth=SPACE(2)
- cDayOfWeek=SPACE(2)
- cDay=SPACE(2)
- cHour=SPACE(2)
- cMinute=SPACE(2)
- cSecond=SPACE(2)
- cMilliSec=SPACE(2)
-
- nYear=0
- nMonth=0
- nDayOfWeek=0
- nDay=0
- nHour=0
- nMinute=0
- nSecond=0
- nMilliSec=0
-
- tLocalDateTime=DATETIME()
- tUTCDateTime=DATETIME()
-
- FUNCTION Init
- ENDFUNC
-
- FUNCTION cYear_assign
- LPARAMETERS lcNewVal
- this.cYear=lcNewVal
- this.nYear=this.strToWord(lcNewVal)
- ENDFUNC
-
- FUNCTION cMonth_assign
- LPARAMETERS lcNewVal
- this.cMonth=lcNewVal
- this.nMonth=this.strToWord(lcNewVal)
- ENDFUNC
-
- FUNCTION cDayOfWeek_assign
- LPARAMETERS lcNewVal
- this.cDayOfWeek=lcNewVal
- this.nDayOfWeek=this.strToWord(lcNewVal)
- ENDFUNC
-
- FUNCTION cDay_assign
- LPARAMETERS lcNewVal
- this.cDay=lcNewVal
- this.nDay=this.strToWord(lcNewVal)
- ENDFUNC
-
- FUNCTION cHour_assign
- LPARAMETERS lcNewVal
- this.cHour=lcNewVal
- this.nHour=this.strToWord(lcNewVal)
- ENDFUNC
-
- FUNCTION cMinute_assign
- LPARAMETERS lcNewVal
- this.cDayOfWeek=lcNewVal
- this.nDayOfWeek=this.strToWord(lcNewVal)
- ENDFUNC
-
- FUNCTION cSecond_assign
- LPARAMETERS lcNewVal
- this.cSecond=lcNewVal
- this.nSecond=this.strToWord(lcNewVal)
- ENDFUNC
-
- FUNCTION cMilliSec_assign
- LPARAMETERS lcNewVal
- this.cMilliSec=lcNewVal
- this.nMilliSec=this.strToWord(lcNewVal)
- ENDFUNC
-
- FUNCTION strToWord
- LPARAMETERS lcVal
- return ASC(LEFT(lcVal,1))+256*ASC(RIGHT(lcVal,1))
- ENDFUNC
-
- FUNCTION Destroy
- CLEAR DLLS "GetLocalTime","GetSystemTime"
- ENDFUNC
-
- PROCEDURE GetUTC
- LOCAL lcBuff
- lcBuff=REPLICATE(CHR(32), SizeOfSystemTime)
- DECLARE GetSystemTime IN WIN32API String@ pST
- GetSystemTime(@lcbuff)
- this.cYear=SUBSTR(lcBuff,1,2)
- this.cMonth=SUBSTR(lcBuff,3,2)
- this.cDayOfWeek=SUBSTR(lcBuff,5,2)
- this.cDay=SUBSTR(lcBuff,7,2)
- this.cHour=SUBSTR(lcBuff,9,2)
- this.cMinute=SUBSTR(lcBuff,11,2)
- this.cSecond=SUBSTR(lcBuff,13,2)
- this.cMilliSec=SUBSTR(lcBuff,15,2)
- ENDPROC
-
- PROCEDURE GetLocal
- LOCAL lcBuff
- DECLARE GetLocalTime IN WIN32API String@ pST
- lcBuff=REPLICATE(CHR(32), SizeOfSystemTime)
- GetLocalTime(@lcbuff)
- this.cYear=SUBSTR(lcBuff,1,2)
- this.cMonth=SUBSTR(lcBuff,3,2)
- this.cDayOfWeek=SUBSTR(lcBuff,5,2)
- this.cDay=SUBSTR(lcBuff,7,2)
- this.cHour=SUBSTR(lcBuff,9,2)
- this.cMinute=SUBSTR(lcBuff,11,2)
- this.cSecond=SUBSTR(lcBuff,13,2)
- this.cMilliSec=SUBSTR(lcBuff,15,2)
- ENDPROC
-
- FUNCTION DateTime
- WITH this
- RETURN DATETIME(.nYear, .nMonth, .nDay, .nHour, .nMinute, .nSecond)
- ENDWITH
- ENDFUNC
-
- ENDDEFINE
m.lcSt=CREATEOBJECT("SystemTime")
m.lcSt.GetUTC()
m.tUTC = m.lcSt.DateTime()
m.lcSt.GetLocal()
m.tLocal = m.lcSt.DateTime()
? m.tLocal-m.tUtc, "secondes d'écart entre UTC et Local"
? (m.tLocal-m.tUtc)/60, "minutes"
? (m.tLocal-m.tUtc)/3600, "heures"
DEFINE CLASS SystemTime as custom
* SYSTEMTIME est composé de 8 WORD (soient 16 octets)
#define SizeOfSystemTime 8*2
cYear=SPACE(2)
cMonth=SPACE(2)
cDayOfWeek=SPACE(2)
cDay=SPACE(2)
cHour=SPACE(2)
cMinute=SPACE(2)
cSecond=SPACE(2)
cMilliSec=SPACE(2)
nYear=0
nMonth=0
nDayOfWeek=0
nDay=0
nHour=0
nMinute=0
nSecond=0
nMilliSec=0
tLocalDateTime=DATETIME()
tUTCDateTime=DATETIME()
FUNCTION Init
ENDFUNC
FUNCTION cYear_assign
LPARAMETERS lcNewVal
this.cYear=lcNewVal
this.nYear=this.strToWord(lcNewVal)
ENDFUNC
FUNCTION cMonth_assign
LPARAMETERS lcNewVal
this.cMonth=lcNewVal
this.nMonth=this.strToWord(lcNewVal)
ENDFUNC
FUNCTION cDayOfWeek_assign
LPARAMETERS lcNewVal
this.cDayOfWeek=lcNewVal
this.nDayOfWeek=this.strToWord(lcNewVal)
ENDFUNC
FUNCTION cDay_assign
LPARAMETERS lcNewVal
this.cDay=lcNewVal
this.nDay=this.strToWord(lcNewVal)
ENDFUNC
FUNCTION cHour_assign
LPARAMETERS lcNewVal
this.cHour=lcNewVal
this.nHour=this.strToWord(lcNewVal)
ENDFUNC
FUNCTION cMinute_assign
LPARAMETERS lcNewVal
this.cDayOfWeek=lcNewVal
this.nDayOfWeek=this.strToWord(lcNewVal)
ENDFUNC
FUNCTION cSecond_assign
LPARAMETERS lcNewVal
this.cSecond=lcNewVal
this.nSecond=this.strToWord(lcNewVal)
ENDFUNC
FUNCTION cMilliSec_assign
LPARAMETERS lcNewVal
this.cMilliSec=lcNewVal
this.nMilliSec=this.strToWord(lcNewVal)
ENDFUNC
FUNCTION strToWord
LPARAMETERS lcVal
return ASC(LEFT(lcVal,1))+256*ASC(RIGHT(lcVal,1))
ENDFUNC
FUNCTION Destroy
CLEAR DLLS "GetLocalTime","GetSystemTime"
ENDFUNC
PROCEDURE GetUTC
LOCAL lcBuff
lcBuff=REPLICATE(CHR(32), SizeOfSystemTime)
DECLARE GetSystemTime IN WIN32API String@ pST
GetSystemTime(@lcbuff)
this.cYear=SUBSTR(lcBuff,1,2)
this.cMonth=SUBSTR(lcBuff,3,2)
this.cDayOfWeek=SUBSTR(lcBuff,5,2)
this.cDay=SUBSTR(lcBuff,7,2)
this.cHour=SUBSTR(lcBuff,9,2)
this.cMinute=SUBSTR(lcBuff,11,2)
this.cSecond=SUBSTR(lcBuff,13,2)
this.cMilliSec=SUBSTR(lcBuff,15,2)
ENDPROC
PROCEDURE GetLocal
LOCAL lcBuff
DECLARE GetLocalTime IN WIN32API String@ pST
lcBuff=REPLICATE(CHR(32), SizeOfSystemTime)
GetLocalTime(@lcbuff)
this.cYear=SUBSTR(lcBuff,1,2)
this.cMonth=SUBSTR(lcBuff,3,2)
this.cDayOfWeek=SUBSTR(lcBuff,5,2)
this.cDay=SUBSTR(lcBuff,7,2)
this.cHour=SUBSTR(lcBuff,9,2)
this.cMinute=SUBSTR(lcBuff,11,2)
this.cSecond=SUBSTR(lcBuff,13,2)
this.cMilliSec=SUBSTR(lcBuff,15,2)
ENDPROC
FUNCTION DateTime
WITH this
RETURN DATETIME(.nYear, .nMonth, .nDay, .nHour, .nMinute, .nSecond)
ENDWITH
ENDFUNC
ENDDEFINE
Conclusion
Historique
- 28 avril 2005 08:19:11 :
- côrecsion d'un fote hortografic
Sources de la même categorie
Commentaires
Discussions en rapport avec ce code source
|
CalendriCode
| | | L | M | M | J | V | S | D |
| | | | 1 | 2 | 3 | 4 |
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
|
Téléchargements
Logiciels à télécharger sur le même thème :
|