Calculator to add time intervals
Instead of subtracting the day_in_seconds repeatedly you could divide the total seconds by day_in_seconds and then set seconds equal to (seconds % days_in_seconds). 

Something like:

if(seconds/days_in_seconds &gt; 0) {
    days = seconds/days_in_seconds;
    seconds = seconds%days_in_seconds;
}


And so on for the other values..

Hope that helps (Posting from mobile)