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) );
27
28echo "-- Tests without valid name - uses gmtOffset and isdst to find match --\n";
29var_dump( timezone_name_from_abbr("", 3600, 1) );
30var_dump( timezone_name_from_abbr("FOO", -7200, 1) );
31var_dump( timezone_name_from_abbr("", -14400, 1) );
32var_dump( timezone_name_from_abbr("", -14400, 0) );
33
34echo "-- Tests with invalid offsets --\n";
35var_dump( timezone_name_from_abbr("", 5400) ); // offset = 1.5 hrs
36var_dump( timezone_name_from_abbr("", 62400) ); // offset = 24 hrs
37?>
38===DONE===
39--EXPECT--
40*** Testing timezone_name_from_abbr() : basic functionality ***
41-- Tests with special cases first - no lookup needed --
42string(3) "UTC"
43string(3) "UTC"
44-- Lookup with just name --
45string(13) "Europe/Berlin"
46string(16) "America/New_York"
47-- Lookup with name and offset--
48string(15) "America/Halifax"
49string(15) "America/Halifax"
50-- Tests without valid name - uses gmtOffset and isdst to find match --
51string(13) "Europe/London"
52string(17) "America/Sao_Paulo"
53string(16) "America/New_York"
54string(15) "America/Halifax"
55-- Tests with invalid offsets --
56bool(false)
57bool(false)
58===DONE===
59