unixtojd.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. unixtojd()
  3. --EXTENSIONS--
  4. calendar
  5. --ENV--
  6. TZ=UTC
  7. --FILE--
  8. <?php
  9. // this line has no impact on test output on Windows
  10. putenv('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. echo unixtojd(). "\n";
  33. echo unixtojd(40000). "\n";
  34. echo unixtojd(1000000000). "\n";
  35. echo unixtojd(1152459009). "\n";
  36. ?>
  37. --EXPECTF--
  38. %d
  39. 2440588
  40. 2452162
  41. 2453926