0) { $temp = $st0_in; $st0_in = $st1_in; $st1_in = $temp; } // //Extract components. // sscanf(SubStr($st0_in, 2), "%04d%02d%02d%02d%02d", $year0, $month0, $day0, $hour0, $minute0); sscanf(SubStr($st1_in, 2), "%04d%02d%02d%02d%02d", $year1, $month1, $day1, $hour1, $minute1); // //Calculate relative offset of dates in minutes. // $dayoffset0 = 24 * 60 * (DATEFUNC_year_predecessor_sum($year0) + DATEFUNC_year_julian_offset($year0, $month0, $day0)); $dayoffset1 = 24 * 60 * (DATEFUNC_year_predecessor_sum($year1) + DATEFUNC_year_julian_offset($year1, $month1, $day1)); // //Calculate relative offset of times in minutes. $minuteoffset0 = $hour0 * 60 + $minute0; $minuteoffset1 = $hour1 * 60 + $minute1; $diffminutes = ($dayoffset1 + $minuteoffset1) - ($dayoffset0 + $minuteoffset0); //Figure out which display format to use. if ($diffminutes < 60) { //a $rv = sprintf("%dm", $diffminutes); } else if ($diffminutes < 2880) { //b $inthours = (int)($diffminutes/60); $leftoverminutes = $diffminutes - ($inthours * 60); $rv = sprintf("%dh %dm", $inthours, $leftoverminutes); } else if ($diffminutes < 7200) { //c $intdays = (int)($diffminutes/1440); $leftoverminutes = $diffminutes - ($intdays * 1440); $inthours = (int)($leftoverminutes / 60); $rv = sprintf("%dd %dh", $intdays, $inthours); } else { //d $rv = sprintf("%dd", (int)($diffminutes/1440)); } return($rv); } // //-------------------------------------------------------------------------------- //Returns a 2-character day-of-week representation of the date of an STIME. //Values are Su, Mo, Tu, We, Th, Fr, Sa. // function STIME_dow_string_a($st_in) { //Extract components. // sscanf(SubStr($st_in, 2), "%04d%02d%02d", $year, $month, $day); // //Calculate day of week. $dow = DATEFUNC_intdayofweek_intdate($year, $month, $day); // //Calc the string, return to caller. return(SubStr("SuMoTuWeThFrSa", $dow*2, 2)); } // //-------------------------------------------------------------------------------- //Reformats an STIME string to include dots at strategic places for more //human-friendly display. // function STIME_dotted_display_string_a($stime_in) { if (! is_string($stime_in)) { //Don't know what this is ... it isn't an stime. Just send it back. return($stime_in); } else if (strlen($stime_in) != 22) { //This doesn't seem to be the right length for an stime. Give it back. return($stime_in); } else { //Seems right. return( SubStr($stime_in, 0, 2) . "." . SubStr($stime_in, 2, 4) . "." . SubStr($stime_in, 6, 2) . "." . SubStr($stime_in, 8, 2) . "." . SubStr($stime_in, 10, 2) . "." . SubStr($stime_in, 12, 2) . "." . SubStr($stime_in, 14, 2) . "." . SubStr($stime_in, 16, 6) ); } } // //-------------------------------------------------------------------------------- //End of $RCSfile: stimex.inc,v $. //-------------------------------------------------------------------------------- ?>