1--TEST--
2Test timezone_name_from_abbr() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : string timezone_name_from_abbr  ( string $abbr  [, int $gmtOffset= -1  [, int $isdst= -1  ]] )
6 * Description: Returns the timezone name from abbrevation
7 * Source code: ext/date/php_date.c
8 * Alias to functions:
9 */
10
11echo "*** Testing timezone_name_from_abbr() : basic functionality ***\n";
12
13//Set the default time zone
14date_default_timezone_set("Europe/London");
15
16echo "-- Tests with special cases first - no lookup needed --\n";
17var_dump( timezone_name_from_abbr("GMT") );
18var_dump( timezone_name_from_abbr("UTC") );
19
20echo "-- Lookup with just name --\n";
21var_dump( timezone_name_from_abbr("CET") );
22var_dump( timezone_name_from_abbr("EDT") );
23
24echo "-- Lookup with name and offset--\n";
25var_dump( timezone_name_from_abbr("ADT", -10800) );
26var_dump( timezone_name_from_abbr("ADT", 14400) );
27var_dump( timezone_name_from_abbr("AKTT", 14400) );
28var_dump( timezone_name_from_abbr("aktt", 18000) );
29var_dump( timezone_name_from_abbr("Aktt", 21600) );
30var_dump( timezone_name_from_abbr("AMST", -10800) );
31var_dump( timezone_name_from_abbr("amst", 180000) );
32
33echo "-- Tests without valid name - uses gmtOffset and isdst to find match --\n";
34var_dump( timezone_name_from_abbr("", 3600, 1) );
35var_dump( timezone_name_from_abbr("FOO", -7200, 1) );
36var_dump( timezone_name_from_abbr("", -14400, 1) );
37var_dump( timezone_name_from_abbr("", -14400, 0) );
38
39echo "-- Tests with invalid offsets --\n";
40var_dump( timezone_name_from_abbr("", 5400) ); // offset = 1.5 hrs
41var_dump( timezone_name_from_abbr("", 62400) ); // offset = 24 hrs
42?>
43===DONE===
44--EXPECTF--
45*** Testing timezone_name_from_abbr() : basic functionality ***
46-- Tests with special cases first - no lookup needed --
47string(3) "UTC"
48string(3) "UTC"
49-- Lookup with just name --
50string(13) "Europe/Berlin"
51string(16) "America/New_York"
52-- Lookup with name and offset--
53string(15) "America/Halifax"
54string(12) "Asia/Baghdad"
55string(11) "Asia/Aqtobe"
56string(11) "Asia/Aqtobe"
57string(11) "Asia/Aqtobe"
58string(17) "America/Boa_Vista"
59string(12) "Asia/Yerevan"
60-- Tests without valid name - uses gmtOffset and isdst to find match --
61string(13) "Europe/London"
62string(17) "America/Sao_Paulo"
63string(16) "America/New_York"
64string(15) "America/Halifax"
65-- Tests with invalid offsets --
66bool(false)
67bool(false)
68===DONE===