Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F8197639
timezone_converter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
timezone_converter.php
View Options
<?php
class
timezone_converter
extends
PHPUnit_Framework_TestCase
{
function
setUp
()
{
}
function
test_list_timezones
()
{
$converter
=
timezone_converter_test
::
getInstance
();
$input
=
'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAEAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAEAAAAAAAAAxP///w=='
;
$output
=
$converter
->
getListOfTimezones
(
$input
);
$this
->
assertTrue
(
is_array
(
$output
));
}
function
test_get_timezone
()
{
$converter
=
timezone_converter_test
::
getInstance
();
$datetime
=
new
DateTime
(
'2017-01-01T12:00:00Z'
);
$offsets
=
$converter
->
getOffsetsForTimezone
(
'UTC'
,
$datetime
);
$output
=
$converter
->
getTimezone
(
$offsets
,
'UTC'
);
$this
->
assertSame
(
'UTC'
,
$output
);
$offsets
=
$converter
->
getOffsetsForTimezone
(
'Europe/Warsaw'
,
$datetime
);
$output
=
$converter
->
getTimezone
(
$offsets
,
'Europe/Warsaw'
);
$this
->
assertSame
(
'Europe/Warsaw'
,
$output
);
$offsets
=
$converter
->
getOffsetsForTimezone
(
'America/Los_angeles'
,
$datetime
);
$output
=
$converter
->
getTimezone
(
$offsets
,
'America/Los_Angeles'
);
$this
->
assertSame
(
'America/Los_Angeles'
,
$output
);
}
function
test_get_offsets_for_timezone
()
{
$converter
=
timezone_converter_test
::
getInstance
();
$datetime
=
new
DateTime
(
'2017-01-01T12:00:00Z'
);
$output
=
$converter
->
getOffsetsForTimezone
(
'UTC'
,
$datetime
);
$this
->
assertSame
(
$output
[
'bias'
],
0
);
$this
->
assertSame
(
$output
[
'standardBias'
],
0
);
$this
->
assertSame
(
$output
[
'daylightBias'
],
0
);
$this
->
assertSame
(
$output
[
'standardMonth'
],
0
);
$this
->
assertSame
(
$output
[
'daylightMonth'
],
0
);
$output
=
$converter
->
getOffsetsForTimezone
(
'Europe/Warsaw'
,
$datetime
);
$this
->
assertSame
(
$output
[
'standardBias'
],
0
);
$this
->
assertSame
(
$output
[
'standardMonth'
],
10
);
$this
->
assertSame
(
$output
[
'standardDay'
],
5
);
$this
->
assertSame
(
$output
[
'standardHour'
],
3
);
$this
->
assertSame
(
$output
[
'daylightBias'
],
-
60
);
$this
->
assertSame
(
$output
[
'daylightMonth'
],
3
);
$this
->
assertSame
(
$output
[
'daylightDay'
],
5
);
$this
->
assertSame
(
$output
[
'daylightHour'
],
2
);
$output
=
$converter
->
getOffsetsForTimezone
(
'America/Los_Angeles'
,
$datetime
);
$this
->
assertSame
(
$output
[
'bias'
],
480
);
$this
->
assertSame
(
$output
[
'standardBias'
],
0
);
$this
->
assertSame
(
$output
[
'standardMonth'
],
11
);
$this
->
assertSame
(
$output
[
'standardDay'
],
1
);
$this
->
assertSame
(
$output
[
'standardHour'
],
2
);
$this
->
assertSame
(
$output
[
'daylightBias'
],
-
60
);
$this
->
assertSame
(
$output
[
'daylightMonth'
],
3
);
$this
->
assertSame
(
$output
[
'daylightDay'
],
2
);
$this
->
assertSame
(
$output
[
'daylightHour'
],
2
);
$output
=
$converter
->
getOffsetsForTimezone
(
'Atlantic/Azores'
,
$datetime
);
$this
->
assertSame
(
$output
[
'bias'
],
60
);
$this
->
assertSame
(
$output
[
'standardBias'
],
0
);
$this
->
assertSame
(
$output
[
'standardMonth'
],
10
);
$this
->
assertSame
(
$output
[
'standardDay'
],
5
);
$this
->
assertSame
(
$output
[
'standardHour'
],
1
);
$this
->
assertSame
(
$output
[
'daylightBias'
],
-
60
);
$this
->
assertSame
(
$output
[
'daylightMonth'
],
3
);
$this
->
assertSame
(
$output
[
'daylightDay'
],
5
);
$this
->
assertSame
(
$output
[
'daylightHour'
],
0
);
}
}
class
timezone_converter_test
extends
kolab_sync_timezone_converter
{
// disable cache
function
getCache
()
{
return
null
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Jul 8, 5:27 PM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1051177
Default Alt Text
timezone_converter.php (3 KB)
Attached To
Mode
R4 syncroton
Attached
Detach File
Event Timeline
Log In to Comment