Results 1 to 10 of 10
  1. #1
    tcr
    tcr is offline Member
    Join Date
    Aug 2014
    Posts
    5
    Rep Power
    0

    Exclamation Timesheet Program

    Hi,


    I am working on a time sheet program. I want to split punches into three parts.

    Suppose an employee punch in at 8:45 am and punch out at 5:30 pm.

    If the shift is 9:00 am to 4:30 , i want to split the above time period to period before shift, period in shift and period after shift.

    In this case :-


    8:45 am -9:00 am
    9:00 am -4:30 pm
    4:30 pm -5:30 pm

    He had worked 15 minutes prior to his shift, 7.5 hours in his shift and 1 hour after his shift.

    I want to do this to calculate regular hours and over time.

    Is there any easy way to split this time interval ??

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,994
    Rep Power
    5

    Default Re: Timesheet Program

    Easy is something very relative. What is easy to me is still difficult to you since you are new to this.

    Try rethinking your question so you actually ask what you want to know.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    tcr
    tcr is offline Member
    Join Date
    Aug 2014
    Posts
    5
    Rep Power
    0

    Default Re: Timesheet Program

    I mean any built in function to do this or any function that require minimal code...

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: Timesheet Program

    I doubt it.
    It's pretty specific.
    In any case, it's a fairly straight forward (at first glance) calculation.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,994
    Rep Power
    5

    Default Re: Timesheet Program

    Quote Originally Posted by tcr View Post
    I mean any built in function to do this or any function that require minimal code...
    That sounds like you are a programmer who doesn't like to write even a small amount of code (or think about how to do it). That's like a farmer who doesn't want to get his hands dirty.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    tcr
    tcr is offline Member
    Join Date
    Aug 2014
    Posts
    5
    Rep Power
    0

    Default Re: Timesheet Program

    Quote Originally Posted by gimbal2 View Post
    That sounds like you are a programmer who doesn't like to write even a small amount of code (or think about how to do it). That's like a farmer who doesn't want to get his hands dirty.
    I already completed a complex coding in which i process each full punch in a while loop without splitting it and it is working fine. But it is not easy to modify by someone else. But any advanced programmers may know if there is any built in functions for that...

  7. #7
    tcr
    tcr is offline Member
    Join Date
    Aug 2014
    Posts
    5
    Rep Power
    0

    Default Re: Timesheet Program

    I know how to do this using basic java. I don't need to bee an advanced programmer to do that.I want to know if there is any advanced way for doing this..

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,994
    Rep Power
    5

    Default Re: Timesheet Program

    You make no sense. An "advanced way" ??? What does that even mean? What is your definition of 'advanced'?

    You want to fix problems that are not there. You're not really experienced yet, there is nothing wrong with that; we all start out that way. You will write code which is not the best code in the world yet; nothing wrong with that, as you get more experienced that will improve.

    At this point you either stick with what you have or you post your code so we can see what can be improved in it so you might learn in the process. But get off this "advanced way of doing it" line of thinking, it really makes no sense and I wish I had the words to explain to you why not exactly - but I'm not a good teacher in that respect.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,519
    Blog Entries
    7
    Rep Power
    20

    Default Re: Timesheet Program

    Basically you want to compare two times T1 and T2 (both in the same day?) and check their difference (measured in minutes?); see what the Calendar class (and/or compadres) can do for you ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    tcr
    tcr is offline Member
    Join Date
    Aug 2014
    Posts
    5
    Rep Power
    0

    Default Re: Timesheet Program

    Ok..

    I will post my code for any suggestion.

    A few thinks to note..

    1) Each punch( in out combination) is already split to different dates.So both in and out would be on same day.
    2) shiftstart and shiftend are used to specify a shift.

    Here 9:00 am to 4:30 pm
    then shiftstart=9:00 am and shiftend=4:30 pm.
    3)in punch and out punch are of type "timestamp"
    4)After splitting the punch the output would be a two dimensional array in which first row would be the part before the shift, second row the part in shift, and third row after shift.

    Here is my code.. just logic

    if(in<shiftstart)
    {
    a[0][0]=in;
    if(out>shiftstart)
    {
    a[0][1]=shiftstart;
    in=shiftstart;
    }
    }


    if(in>=shiftstart && in<shiftend)
    {
    a[1][0]=in;
    if(out>shiftend)
    {
    a[1][1]=shiftend;
    in=shiftend;
    }
    else
    {
    a[1][1]=out;
    }

    }

    if(in>=shiftend)
    {
    a[2][0]=in;
    a[2][1]=out;
    }

    Thats all..

    if the punch is 8:00 am to 5:00 pm

    a[0][0] and a[0][1] = 8:00 am 9:00 am
    a[1][0] and a[1][1] = 9:00 am 4:30 pm
    a[2][0] and a[2][1] = 4:30 pm 5:00 pm

    Any suggestion or improvement please..??

Similar Threads

  1. Replies: 6
    Last Post: 12-15-2013, 06:40 AM
  2. Replies: 4
    Last Post: 11-21-2012, 01:19 PM
  3. Replies: 2
    Last Post: 04-02-2011, 12:57 PM
  4. Replies: 13
    Last Post: 03-22-2011, 06:49 AM
  5. Replies: 0
    Last Post: 04-04-2008, 02:40 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •