File: timezone_name_from_abbr_basic1.phpt

package info (click to toggle)
php8.4 8.4.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 211,276 kB
  • sloc: ansic: 1,176,142; php: 35,419; sh: 11,964; cpp: 7,208; pascal: 4,951; javascript: 3,091; asm: 2,817; yacc: 2,411; makefile: 696; xml: 446; python: 301; awk: 148
file content (50 lines) | stat: -rw-r--r-- 1,719 bytes parent folder | download | duplicates (3)
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
--TEST--
Test timezone_name_from_abbr() function : basic functionality
--FILE--
<?php
echo "*** Testing timezone_name_from_abbr() : basic functionality ***\n";

//Set the default time zone
date_default_timezone_set("Europe/London");

echo "-- Tests with special cases first - no lookup needed --\n";
var_dump( timezone_name_from_abbr("GMT") );
var_dump( timezone_name_from_abbr("UTC") );

echo "-- Lookup with just name --\n";
var_dump( timezone_name_from_abbr("CET") );
var_dump( timezone_name_from_abbr("EDT") );

echo "-- Lookup with name and offset--\n";
var_dump( timezone_name_from_abbr("ADT", -10800) );
var_dump( timezone_name_from_abbr("ADT", 14400) );

echo "-- Tests without valid name - uses gmtOffset and isdst to find match --\n";
var_dump( timezone_name_from_abbr("", 3600, 1) );
var_dump( timezone_name_from_abbr("FOO", -7200, 1) );
var_dump( timezone_name_from_abbr("", -14400, 1) );
var_dump( timezone_name_from_abbr("", -14400, 0) );

echo "-- Tests with invalid offsets --\n";
var_dump( timezone_name_from_abbr("", 5400) ); // offset = 1.5 hrs
var_dump( timezone_name_from_abbr("", 62400) ); // offset = 24 hrs
?>
--EXPECT--
*** Testing timezone_name_from_abbr() : basic functionality ***
-- Tests with special cases first - no lookup needed --
string(3) "UTC"
string(3) "UTC"
-- Lookup with just name --
string(13) "Europe/Berlin"
string(16) "America/New_York"
-- Lookup with name and offset--
string(15) "America/Halifax"
string(15) "America/Halifax"
-- Tests without valid name - uses gmtOffset and isdst to find match --
string(13) "Europe/London"
string(17) "America/Sao_Paulo"
string(16) "America/New_York"
string(15) "America/Halifax"
-- Tests with invalid offsets --
bool(false)
bool(false)