>DEFINE CLASS txtHourMin AS TextBox > Format = "!" > InputMask = "99:99 AA" > > ****************************************** > FUNCTION KeyPress > LPARAMETERS nKeyCode, nShiftAltCtrl > ****************************************** > LOCAL lnSelStart, lcChr, llRefresh, llHr24 > lcChr = UPPER(CHR(nKeyCode)) > lnSelStart = This.SelStart > llRefresh = .F. > llHr24 = .F. > IF INLIST(nKeyCode, 59, 58) && ";" and ":" > This.SelStart = 3 > NODEFAULT > ELSE > IF ISALPHA(lcChr) > IF INLIST(lcChr, "A", "P") > This.Value = LEFT(This.Value, 5) + " " + lcChr + "M" > llRefresh = .T. > ENDIF > NODEFAULT > ELSE > IF INLIST(nKeyCode, 59, 58) && ";" and ":" > This.SelStart = 3 > NODEFAULT > ENDIF > ENDIF > ENDIF > IF llRefresh > This.Refresh() > This.SelStart = lnSelStart > ENDIF > RETURN .T. > > ************************************* > FUNCTION Valid > ************************************* > LOCAL llReturn, lcThisVal, lcStripVal, ltVal, lcTime > lcThisVal = UPPER(This.Value) > lcStripVal = CHRTRAN(lcThisVal, ":", "") > llReturn = .T. > ltVal = CTOT(lcThisVal) > IF EMPTY(ltVal) > llReturn = EMPTY(lcStripVal) > ELSE > IF NOT ISDIGIT(ALLTRIM(LEFT(lcStripVal, 2))) > llReturn = .F. > ELSE > lcTime = TTOC(ltVal, 2) > This.Value = ALLTRIM(LEFT(lcTime, 5) + SUBSTR(lcTime, AT(" ", lcTime))) > This.Refresh() > ENDIF > ENDIF > RETURN (llReturn) > > ************************************* > FUNCTION CTimeToHM > LPARAMETERS tcTime > ************************************* > LOCAL ltVal, lcThisVal, lcReturn > lcReturn = "" > IF VARTYPE(m.tcTime) = "T" > ltVal = m.tcTime > ELSE > IF VARTYPE(m.tcTime) <> "C" > lcThisVal = UPPER(This.Value) > ELSE > lcThisVal = UPPER(m.tcTime) > ENDIF > ltVal = CTOT(m.lcThisVal) > ENDIF > IF EMPTY(ltVal) > lcReturn = "" > ELSE > lcReturn = PADL(LTRIM(STR(HOUR(ltVal), 2)), 2, "0") + PADL(LTRIM(STR(MINUTE(ltVal), 2)), 2, "0") > ENDIF > RETURN (lcReturn) > > ************************************* > FUNCTION HMtoCtime > LPARAMETERS tcHHMM > ************************************* > LOCAL ltVal, lcThisVal, lcReturn, lcTime > lcReturn = "" > lcThisVal = PADL(m.tcHHMM, MAX(LEN(tcHHMM), 4)) > ltVal = CTOT(LEFT(m.lcThisVal, 2) + ":" + SUBSTR(m.lcThisVal, 3)) > IF EMPTY(ltVal) > lcReturn = "" > ELSE > lcTime = TTOC(ltVal, 2) > lcReturn = ALLTRIM(LEFT(lcTime, 5) + SUBSTR(lcTime, AT(" ", lcTime))) > ENDIF > RETURN (lcReturn) >ENDDEFINE >