Author Topic: deprecated issue in get-USNO script  (Read 138 times)

0 Members and 1 Guest are viewing this topic.

Offline Jasiu

  • Forecaster
  • *****
  • Posts: 951
    • LexMAWeather
deprecated issue in get-USNO script
« on: March 29, 2024, 11:39:09 AM »
I just noticed a deprecation error in the get-USNO-sunmoon.php script in the formatTime() function.

Quote
Deprecated: Implicit conversion from float 1711771183.7465816 to int loses precision

The two lines where this occurs are where the date() calls are:

Code: [Select]
  // round time, return array(timestamp, "hhmm", "hh:mm")

  private function formatTime($t)
  {
    $t0 = 60 * (int)($t / 60 + 0.5);
    if (date("j", (integer)$t) == date("j", $t0)) $t = $t0;
    return array(
      $t,
      date("Hi", $t) ,
      date("H:i", $t)
    );
  }

Converting $t to "int" within those calls fixes it, but my question (to Ken I guess) is should the timestamp ($t) also be returned from the function as an integer?
https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

 

anything