xref: /PHP-7.4/ext/calendar/tests/unixtojd.phpt (revision ebdbebee)
1--TEST--
2unixtojd()
3--SKIPIF--
4<?php include 'skipif.inc'; ?>
5--ENV--
6TZ=UTC
7--FILE--
8<?php
9// this line has no impact on test output on Windows
10putenv('TZ=UTC');
11// getenv('TZ') returns 'UTC' here
12// putenv (basic_functions.c) does call tzset() when the env var being put is 'TZ'
13//      -adding a call direct to GetEnvironmentVariableA just before tzset() is called to check the value of 'TZ' returns 'UTC'
14// putting a call to date_default_timezone_set() here doesn't help
15//
16// on Windows, the only thing that gets this test to pass is to put TZ=UTC in --ENV-- section
17// 		-since putenv() is written to call tzset() when env var is TZ, I assume that putenv("TZ=UTC") is intended to work
18//			and should work on all platforms(including Windows).
19// easter_date.phpt passes
20//		-doesn't use --ENV-- section
21//		-uses --INI-- section with date.timezone=UTC
22//		-uses putenv('TZ=UTC')
23// date.timezone=UTC
24//		-if omitted from easter_date.phpt, outputs DATE_TZ_ERRMSG warning
25//			-easter_date() calls mktime() and localtime()
26//			-whereas unixtojd(1000000000) calls localtime(1000000000)
27//		-if omitted from unixtojd.phpt, does NOT output DATE_TZ_ERRMSG
28//
29// unixtojd() calls php_localtime_r() which for Pacific timezone systems, returns a time -8 hours
30//		-this incorrect localtime is passed to the julian date conversion (GregorianToSDN) function which works (probably correctly)
31//			but returns -1 day from expected because its input is -1 from expected
32
33echo unixtojd(). "\n";
34echo unixtojd(40000). "\n";
35echo unixtojd(1000000000). "\n";
36echo unixtojd(1152459009). "\n";
37?>
38--EXPECTF--
39%d
402440588
412452162
422453926
43