ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
DateHandler.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Andreas Åkre Solberg <andreas.solberg@uninett.no>
4  * @package SimpleSAMLphp
5  */
7 {
8  protected $offset;
9 
15  public function __construct($offset)
16  {
17  $this->offset = $offset;
18  }
19 
20  protected function getDST($timestamp)
21  {
22  if (idate('I', $timestamp)) {
23  return 3600;
24  }
25  return 0;
26  }
27 
28  public function toSlot($epoch, $slotsize)
29  {
30  $dst = $this->getDST($epoch);
31  return floor( ($epoch + $this->offset + $dst) / $slotsize);
32  }
33 
34  public function fromSlot($slot, $slotsize)
35  {
36  $temp = $slot*$slotsize - $this->offset;
37  $dst = $this->getDST($temp);
38  return $slot*$slotsize - $this->offset - $dst;
39  }
40 
41  public function prettyDateEpoch($epoch, $dateformat)
42  {
43  return date($dateformat, $epoch);
44  }
45 
46  public function prettyDateSlot($slot, $slotsize, $dateformat)
47  {
48  return $this->prettyDateEpoch($this->fromSlot($slot, $slotsize), $dateformat);
49  }
50 
51  public function prettyHeader($from, $to, $slotsize, $dateformat)
52  {
53  $text = $this->prettyDateSlot($from, $slotsize, $dateformat);
54  $text .= ' to ';
55  $text .= $this->prettyDateSlot($to, $slotsize, $dateformat);
56  return $text;
57  }
58 }
toSlot($epoch, $slotsize)
Definition: DateHandler.php:28
$dst
$from
fromSlot($slot, $slotsize)
Definition: DateHandler.php:34
prettyDateSlot($slot, $slotsize, $dateformat)
Definition: DateHandler.php:46
prettyHeader($from, $to, $slotsize, $dateformat)
Definition: DateHandler.php:51
$text
Definition: errorreport.php:18
__construct($offset)
Constructor.
Definition: DateHandler.php:15
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
prettyDateEpoch($epoch, $dateformat)
Definition: DateHandler.php:41