ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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

◆ _test()

ilBMFType_duration::_test (   $time)

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

127 {
130 echo "Duration: $time is ".$t." seconds\n";
131 } else {
133 echo "Seconds: $time is ".$t." duration\n";
134 }
135 return $t;
136 }

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

+ Here is the call graph for this function:

◆ add()

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:

◆ duration_to_unix()

ilBMFType_duration::duration_to_unix (   $duration)

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

114 {
115 global $ereg_duration;
116 if (ereg($ereg_duration,$duration,$regs)) {
117 return ilBMFType_duration::mkduration($regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6], $regs[7]);
118 }
119 return FALSE;
120 }
mkduration($n, $Y, $Mo, $D, $H, $Mi, $S)

References $ereg_duration, and mkduration().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getduration()

ilBMFType_duration::getduration (   $seconds)

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

69 {
70 $neg = '';
71 if ($seconds < 0) {
72 $neg = '-';
73 $seconds = $seconds * -1;
74 }
75
76 $_mi = 60;
77 $_h = $_mi * 60;
78 $_d = $_h * 24;
79 // XXX how do we properly handle month and year values?
80 $_m = $_d * 30;
81 $_y = $_d * 365;
82
83 ilBMFType_duration::mod($seconds, $_y, $y, $seconds);
84 ilBMFType_duration::mod($seconds, $_m, $m, $seconds);
85 ilBMFType_duration::mod($seconds, $_d, $d, $seconds);
86 ilBMFType_duration::mod($seconds, $_h, $h, $seconds);
87 ilBMFType_duration::mod($seconds, $_mi, $mi, $s);
88
89 $duration = $neg.'P';
90 if ($y) $duration .= $y.'Y';
91 if ($m) $duration .= $m.'M';
92 if ($d) $duration .= $d.'D';
93 if ($h || $mi || $s) $duration .='T';
94 if ($h) $duration .= $h.'H';
95 if ($mi) $duration .= $mi.'M';
96 if ($s) $duration .= $s.'S';
97 if ($duration == 'P' || $duration == '-P') $duration = 'PT0S';
98 return $duration;
99 }

References $d, and mod().

Referenced by unix_to_duration().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_duration()

ilBMFType_duration::is_duration (   $duration)

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

122 {
123 global $ereg_duration;
124 return ereg($ereg_duration,$duration,$regs);
125 }

References $ereg_duration.

Referenced by _test().

+ Here is the caller graph for this function:

◆ mkduration()

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

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

101 {
102 $_mi = 60;
103 $_h = $_mi * 60;
104 $_d = $_h * 24;
105 // XXX how do we properly handle month and year values?
106 $_m = $_d * 30;
107 $_y = $_d * 365;
108
109 $sec = $Y * $_y + $Mo * $_m + $D * $_d + $H * $_h + $Mi * $_mi + $S;
110 if ($n == '-') $sec = $sec * -1;
111 return $sec;
112 }
$n
Definition: RandomTest.php:80

References $n.

Referenced by duration_to_unix().

+ Here is the caller graph for this function:

◆ mod()

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

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

64 {
65 $d = floor( $a / $b );
66 $r = $a % $b;
67 }

References $d.

Referenced by getduration().

+ Here is the caller graph for this function:

◆ subtract()

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:

◆ unix_to_duration()

ilBMFType_duration::unix_to_duration (   $seconds)

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

60 {
61 return ilBMFType_duration::getduration($seconds);
62 }

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: