Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Time Card Processing
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01323531
Message ID:
01323612
Views:
14
Do you mean to say that it's working now?
BTW, I notice that in all the three Do-Case constructs the first and second case statements give the same results.

>It looks like plugging away at this may have yielded some results, finally. The code is below our other preceding notes.
>
>>This really sounds very trivial. Are you sure that you don't have any bugs in the functions which converts the datatime values into text and back?
>
>>>The dates and times are stored as character data, such as "06/10/2008-06:00". I didn't build this system from scratch, but inherited it a few years ago.
>>>
>>>>I haven't studied your code, but how is the time stored? If you use datetime fields, this should be extremely easy.
>
>
>* Program to test the Post_Time_Clock. I change the START and END times.
>* Cecil
>
>*dClockedOut=CTOD(LEFT(employee.outtime ,10))
>*dClockedIn =CTOD(LEFT(employee.intime,10))
>dClockedOut={^2008/06/10}
>dClockedIn ={^2008/06/09}
>
>cActualStartTime="22:01"
>cShiftStartTime="22:00"
>cScheduledShiftStartMinute=SUBSTR(cShiftStartTime, 4, 2)
>
>cActualEndTime="06:00"
>cActualEndHour=LEFT(cActualEndTime, 2)
>cActualEndMinute=SUBSTR(cActualEndTime, 4, 2)
>
>cActualStartHour=LEFT(cActualStartTime, 2)
>cActualStartMinute=SUBSTR(cActualStartTime, 4, 2)
>set step on
>IF EMPTY(cShiftStartTime)
>   cScheduledStartMinute="00"
>   IF cActualStartMinute > "15"
>      cScheduledStartHour=STR(VAL(cActualStartHour)+1)
>   ELSE
>      cScheduledStartHour=cActualStartHour
>   ENDIF
>ELSE
>cScheduledStartHour=LEFT(cShiftStartTime,2)
>cScheduledStartMinute=SUBSTR(cShiftStartTime,4,2)
>ENDIF
>cScheduledStartHour=ALLTRIM(cScheduledStartHour)
>cScheduledStartMinute=ALLTRIM(cScheduledStartMinute)
>
>iScheduledStartMinutes=;
>   (60 * VAL(cScheduledStartHour)) + VAL(cScheduledStartMinute)
>iActualStartMinutes=;
>   (60 * VAL(cActualStartHour)) + VAL(cActualStartMinute)
>iEarlyOrLateMinutes =;
>   (iScheduledStartMinutes - iActualStartMinutes)
>
>* The cEffectiveStartHour and cEffectiveStartMinute are used for calculations.
>DO CASE
>   * Employee Clocked In over 15 minutes EARLY. Ex: 05:44.
>   CASE iEarlyOrLateMinutes > 15
>      cEffectiveStartHour=cActualStartHour
>      cEffectiveStartMinute=cActualStartMinute
>   * Employee Clocked In LATE. Ex: 06:01.
>   CASE iEarlyOrLateMinutes < 0
>      cEffectiveStartHour=cActualStartHour
>      cEffectiveStartMinute=cActualStartMinute
>   OTHERWISE	&& Employee Clocked In on time. Scheduled Shift Start.
>      cEffectiveStartHour=cScheduledStartHour
>      cEffectiveStartMinute=cScheduledStartMinute
>ENDCASE
>cEffectiveStartHour=ALLTRIM(cEffectiveStartHour)
>cEffectiveStartMinute=ALLTRIM(cEffectiveStartMinute)
>
>cEffectiveStartTime=;
>   PADL(ALLTRIM(cEffectiveStartHour),2,"0")+;
>   ':'+PADL(ALLTRIM(cEffectiveStartMinute),2,"0")
>
>* Do some calculating to determine the Scheduled End Hour.
>
>* Convert the END HOUR and END MINUTE into END MINUTES.
>iActualEndMinutes=(60 * VAL(cActualEndHour)) + VAL(cActualEndMinute)
>
>* Convert the Effective START HOUR and Effective START MINUTE into Effective Start Minutes.
>iTotalActualShiftHours=VAL(cActualEndHour) - VAL(cEffectiveStartHour)
>
>cScheduledEndHour=STR(VAL(cEffectiveStartHour) + iTotalActualShiftHours)
>cScheduledEndMinute=cScheduledStartMinute
>* Check the 24 hour time and correct it, if necessary.
>cScheduledEndHour=;
>   IIF(VAL(cScheduledEndHour)>23,STR(VAL(cScheduledEndHour)-24),cScheduledEndHour)
>iScheduledEndMinutes=(60 * VAL(cScheduledEndHour)) + VAL(cScheduledEndMinute)
>iEarlyOrLateMinutes=(iScheduledEndMinutes - iActualEndMinutes)
>
>*********************************************
>*** (9F) CLOCK-OUT - EARLY OR LATE TESTS. ***
>*********************************************
>DO CASE
>   CASE iEarlyOrLateMinutes > 0	&& Employee clocked out EARLY. Ex: 13:59.
>      cEffectiveEndHour=cActualEndHour
>      cEffectiveEndMinute=cActualEndMinute
>		
>   CASE iEarlyOrLateMinutes < -15	&& Employee clocked out over 15 minutes LATE. Ex: 14:16.
>      cEffectiveEndHour=cActualEndHour
>      cEffectiveEndMinute=cActualEndMinute
>
>   OTHERWISE  && Normal Shift End.
>      cEffectiveEndHour=cScheduledEndHour
>      cEffectiveEndMinute=cScheduledEndMinute
>ENDCASE
>cEffectiveEndHour=ALLTRIM(cEffectiveEndHour)
>cEffectiveEndMinute=ALLTRIM(cEffectiveEndMinute)
>************************************************************
>* (9G) Put together complete END Time from the above code.
>***************************************************************************
>cEffectiveEndTime=;
>   PADL(ALLTRIM(cEffectiveEndHour),2,"0")-':'-PADL(ALLTRIM(cEffectiveEndMinute),2,"0")
>
>nPayHours=;
>   (1440 * (dClockedOut - dClockedIn)) + ;
>   60*VAL(SUBSTR(cEffectiveEndTime,1,2))+VAL(SUBSTR(cEffectiveEndTime,4,2))- ;
>   60*VAL(SUBSTR(cEffectiveStartTime,1,2))-VAL(SUBSTR(cEffectiveStartTime,4,2))
>
>nPayHours = IIF(nPayHours < 0, 1440 + nPayHours, nPayHours)/60
>nPayHours = ROUND(nPayHours, 2)
>
>ASSERT = .F.
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform