ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilBMFType_duration Class Reference
+ Collaboration diagram for ilBMFType_duration:

Public Member Functions

 unix_to_duration ($seconds)
 mod ($a, $b, &$d, &$r)
 getduration ($seconds)
 mkduration ($n, $Y, $Mo, $D, $H, $Mi, $S)
 duration_to_unix ($duration)
 is_duration ($duration)
 _test ($time)
 add ($d1, $d2)
 subtract ($d1, $d2)

Detailed Description

Definition at line 57 of file class.ilBMFType_duration.php.

Member Function Documentation

ilBMFType_duration::_test (   $time)

Definition at line 127 of file class.ilBMFType_duration.php.

References $t, duration_to_unix(), is_duration(), and unix_to_duration().

{
echo "Duration: $time is ".$t." seconds\n";
} else {
echo "Seconds: $time is ".$t." duration\n";
}
return $t;
}

+ Here is the call graph for this function:

ilBMFType_duration::add (   $d1,
  $d2 
)

Definition at line 138 of file class.ilBMFType_duration.php.

References duration_to_unix(), and unix_to_duration().

+ Here is the call graph for this function:

ilBMFType_duration::duration_to_unix (   $duration)

Definition at line 114 of file class.ilBMFType_duration.php.

References $ereg_duration, and mkduration().

Referenced by _test(), add(), and subtract().

{
if (ereg($ereg_duration,$duration,$regs)) {
return ilBMFType_duration::mkduration($regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6], $regs[7]);
}
return FALSE;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBMFType_duration::getduration (   $seconds)

Definition at line 69 of file class.ilBMFType_duration.php.

References $d, $y, and mod().

Referenced by unix_to_duration().

{
$neg = '';
if ($seconds < 0) {
$neg = '-';
$seconds = $seconds * -1;
}
$_mi = 60;
$_h = $_mi * 60;
$_d = $_h * 24;
// XXX how do we properly handle month and year values?
$_m = $_d * 30;
$_y = $_d * 365;
ilBMFType_duration::mod($seconds, $_y, $y, $seconds);
ilBMFType_duration::mod($seconds, $_m, $m, $seconds);
ilBMFType_duration::mod($seconds, $_d, $d, $seconds);
ilBMFType_duration::mod($seconds, $_h, $h, $seconds);
ilBMFType_duration::mod($seconds, $_mi, $mi, $s);
$duration = $neg.'P';
if ($y) $duration .= $y.'Y';
if ($m) $duration .= $m.'M';
if ($d) $duration .= $d.'D';
if ($h || $mi || $s) $duration .='T';
if ($h) $duration .= $h.'H';
if ($mi) $duration .= $mi.'M';
if ($s) $duration .= $s.'S';
if ($duration == 'P' || $duration == '-P') $duration = 'PT0S';
return $duration;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilBMFType_duration::is_duration (   $duration)

Definition at line 122 of file class.ilBMFType_duration.php.

References $ereg_duration.

Referenced by _test().

{
return ereg($ereg_duration,$duration,$regs);
}

+ Here is the caller graph for this function:

ilBMFType_duration::mkduration (   $n,
  $Y,
  $Mo,
  $D,
  $H,
  $Mi,
  $S 
)

Definition at line 101 of file class.ilBMFType_duration.php.

References $Y.

Referenced by duration_to_unix().

{
$_mi = 60;
$_h = $_mi * 60;
$_d = $_h * 24;
// XXX how do we properly handle month and year values?
$_m = $_d * 30;
$_y = $_d * 365;
$sec = $Y * $_y + $Mo * $_m + $D * $_d + $H * $_h + $Mi * $_mi + $S;
if ($n == '-') $sec = $sec * -1;
return $sec;
}

+ Here is the caller graph for this function:

ilBMFType_duration::mod (   $a,
  $b,
$d,
$r 
)

Definition at line 64 of file class.ilBMFType_duration.php.

References $d.

Referenced by getduration().

{
$d = floor( $a / $b );
$r = $a % $b;
}

+ Here is the caller graph for this function:

ilBMFType_duration::subtract (   $d1,
  $d2 
)

Definition at line 144 of file class.ilBMFType_duration.php.

References duration_to_unix(), and unix_to_duration().

+ Here is the call graph for this function:

ilBMFType_duration::unix_to_duration (   $seconds)

Definition at line 60 of file class.ilBMFType_duration.php.

References getduration().

Referenced by _test(), add(), and subtract().

{
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: