File: Time.php

package info (click to toggle)
php-horde 5.2.13%2Bdebian0-1%2Bdeb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 12,652 kB
  • sloc: php: 11,153; xml: 6,751; javascript: 5,560; sh: 92; makefile: 33; sql: 1
file content (58 lines) | stat: -rw-r--r-- 1,306 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
 * @package Horde
 */
class Horde_Block_Time extends Horde_Core_Block
{
    /**
     */
    public $updateable = true;

    /**
     */
    public function __construct($app, $params = array())
    {
        parent::__construct($app, $params);

        $this->_name = _("Current Time");
    }

    /**
     */
    protected function _params()
    {
        return array(
            'time' => array(
                'type' => 'enum',
                'name' => _("Time format"),
                'default' => '24-hour',
                'values' => array(
                    '24-hour' => _("24 Hour Format"),
                    '12-hour' => _("12 Hour Format")
                )
            )
        );
    }

    /**
     */
    protected function _content()
    {
        if (empty($this->_params['time'])) {
            $this->_params['time'] = '24-hour';
        }

        // Set the timezone variable, if available.
        $GLOBALS['registry']->setTimeZone();

        $html = '<div style="font-size:200%; font-weight:bold; text-align:center">' .
            strftime('%A, %B %d, %Y ');
        if ($this->_params['time'] == '24-hour') {
            $html .= strftime('%H:%M');
        } else {
            $html .= strftime('%I:%M %p');
        }
        return $html . '</div>';
    }

}