This file is indexed.

/usr/share/php/tests/Horde_Mapi/Horde/Mapi/TimezoneTest.php is in php-horde-mapi 1.0.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
/*
 * Unit tests for Horde_Mapi_Timezone utilities
 *
 * @author Michael J. Rubinsky <mrubinsk@horde.org>
 * @category Horde
 * @package Mapi_Utils
 */
class Horde_Mapi_TimezoneTest extends Horde_Test_Case
{

    protected $_offsets = array(
        'America/New_York'    => array('bias' => 300,
                                       'stdname' => '',
                                       'stdyear' => 0,
                                       'stdmonth' => 11,
                                       'stdday' => 0,
                                       'stdweek' => 1,
                                       'stdhour' => 2,
                                       'stdminute' => 0,
                                       'stdsecond' => 0,
                                       'stdmillis' => 0,
                                       'stdbias' => 0,
                                       'dstname' => '',
                                       'dstyear' => 0,
                                       'dstmonth' => 3,
                                       'dstday' => 0,
                                       'dstweek' => 2,
                                       'dsthour' => 2,
                                       'dstminute' => 0,
                                       'dstsecond' => 0,
                                       'dstmillis' => 0,
                                       'dstbias' => -60),
        'Europe/Berlin'       => array('bias' => -60,
                                       'stdname' => '',
                                       'stdyear' => 0,
                                       'stdmonth' => 10,
                                       'stdday' => 0,
                                       'stdweek' => 5,
                                       'stdhour' => 3,
                                       'stdminute' => 0,
                                       'stdsecond' => 0,
                                       'stdmillis' => 0,
                                       'stdbias' => 0,
                                       'dstname' => '',
                                       'dstyear' => 0,
                                       'dstmonth' => 3,
                                       'dstday' => 0,
                                       'dstweek' => 5,
                                       'dsthour' => 2,
                                       'dstminute' => 0,
                                       'dstsecond' => 0,
                                       'dstmillis' => 0,
                                       'dstbias' => -60),
        'America/Los_Angeles' => array('bias' => 480,
                                       'stdname' => '',
                                       'stdyear' => 0,
                                       'stdmonth' => 11,
                                       'stdday' => 0,
                                       'stdweek' => 1,
                                       'stdhour' => 2,
                                       'stdminute' => 0,
                                       'stdsecond' => 0,
                                       'stdmillis' => 0,
                                       'stdbias' => 0,
                                       'dstname' => '',
                                       'dstyear' => 0,
                                       'dstmonth' => 3,
                                       'dstday' => 0,
                                       'dstweek' => 2,
                                       'dsthour' => 2,
                                       'dstminute' => 0,
                                       'dstsecond' => 0,
                                       'dstmillis' => 0,
                                       'dstbias' => -60,
                                       'timezone' => 480,
                                       'timezonedst' => -60),
        'America/Phoenix'     => array('bias' => 420,
                                       'stdname' => '',
                                       'stdyear' => 0,
                                       'stdmonth' => 0,
                                       'stdday' => 0,
                                       'stdweek' => 0,
                                       'stdhour' => 0,
                                       'stdminute' => 0,
                                       'stdsecond' => 0,
                                       'stdmillis' => 0,
                                       'stdbias' => 0,
                                       'dstname' => '',
                                       'dstyear' => 0,
                                       'dstmonth' => 0,
                                       'dstday' => 0,
                                       'dstweek' => 0,
                                       'dsthour' => 0,
                                       'dstminute' => 0,
                                       'dstsecond' => 0,
                                       'dstmillis' => 0,
                                       'dstbias' => 0)
    );

    protected $_packed = array(
        'America/New_York'    => 'LAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAIAAAAAAAAAxP///w==',
        'America/Los_Angeles' => '4AEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAACAAIAAAAAAAAAxP///w==',
        'Europe/Berlin'       => 'xP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAIAAAAAAAAAxP///w==',
        'America/Phoenix'     => 'pAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==',
    );


    public function setUp()
    {
        $this->_oldTimezone = date_default_timezone_get();
        date_default_timezone_set('America/New_York');
    }

    public function tearDown()
    {
        date_default_timezone_set($this->_oldTimezone);
    }

    /**
     * Test building an Offset hash from a given ActiveSync style base64 encoded
     * timezone structure.
     */
    public function testOffsetsFromSyncTZ()
    {
        foreach ($this->_packed as $tz => $blob) {
            $offsets = Horde_Mapi_Timezone::getOffsetsFromSyncTZ($blob);
            foreach ($this->_offsets[$tz] as $key => $value) {
                $this->assertEquals($value, $offsets[$key]);
            }
        }
    }

    /**
     * Test creating a Offset hash for a given timezone.
     */
    public function testGetOffsetsFromDate()
    {
        // The actual time doesn't matter, we really only need a year and a
        // timezone that we are interested in.
        foreach ($this->_offsets as $tz => $expected) {
            $date = new Horde_Date('2011-07-01', $tz);
            $offsets = Horde_Mapi_Timezone::getOffsetsFromDate($date);
            foreach ($offsets as $key => $value) {
                $this->assertEquals($expected[$key], $value);
            }
        }
    }

    /**
     * Test generating an ActiveSync TZ structure given a TZ Offset hash
     */
    public function testGetSyncTZFromOffsets()
    {
        foreach ($this->_offsets as $tz => $offsets) {
            $blob = Horde_Mapi_Timezone::getSyncTZFromOffsets($offsets);
            $this->assertEquals($this->_packed[$tz], $blob);
        }
    }

    /**
     * Test guessing a timezone identifier from an ActiveSync timezone
     * structure.
     */
    public function testGuessTimezoneFromOffsets()
    {
        $timezones = new Horde_Mapi_Timezone();

        // Test general functionality, with expected timezone.
        foreach ($this->_packed as $tz => $blob) {
            $guessed = $timezones->getTimezone($blob, $tz);
            $this->assertEquals($tz, $guessed);
        }

        // Test without a known timezone
        $guessed = $timezones->getTimezone($this->_packed['America/New_York']);
        $this->assertEquals('EST', $guessed);

        $guessed = $timezones->getTimezone($this->_packed['Europe/Berlin']);
        $this->assertEquals('CET', $guessed);
    }

}