Автор: =undo= (info@wpxtre.me)
Наследование: extends WPDKObject
Пример #1
0
 /**
  * Return the file size (B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB) well formatted. Return FALSE if file doesn't
  * exists or `filesize()` failure.
  *
  * @brief Get the file size
  * @uses  `WPDKMath::bytes()`
  *
  * @param string $filename  File name or path to a file
  * @param int    $precision Digits to display after decimal
  *
  * @return string|bool
  */
 public static function fileSize($filename, $precision = 2)
 {
     if (is_file($filename)) {
         if (!realpath($filename)) {
             $filename = $_SERVER['DOCUMENT_ROOT'] . $filename;
         }
         $bytes = filesize($filename);
         if (false === $bytes) {
             return false;
         }
         return WPDKMath::bytes($bytes, $precision);
     }
     return false;
 }
Пример #2
0
 /**
  * Check if infinity
  *
  * @brief      Infinity
  *
  * @param float|string $value Check value
  *
  * @return bool TRUE if $value is equal to INF (php) or WPDKMath::INFINITY
  *
  * @file       wpdk-functions.php
  * @deprecated Since 1.2.0 Use WPDKMath::isInfinity() instead
  *
  */
 function wpdk_is_infinity($value)
 {
     _deprecated_function(__FUNCTION__, '1.2.0', 'WPDKMath::isInfinity()');
     return WPDKMath::isInfinity($value);
 }
Пример #3
0
 /**
  * Returns number of days to start of this week.
  *
  * @brief      Days number
  *
  * @author     =stid= <*****@*****.**>
  *
  * @param object $date Date object
  * @param string $first_day
  *
  * @return int $date
  */
 public static function daysToWeekStart($date, $first_day = 'monday')
 {
     $week_days = array('monday' => 0, 'tuesday' => 1, 'wednesday' => 2, 'thursday' => 3, 'friday' => 4, 'saturday' => 5, 'sunday' => 6);
     $start_day_number = $week_days[$first_day];
     $wday = $date->format("w");
     $current_day_number = $wday != 0 ? $wday - 1 : 6;
     return WPDKMath::rModulus($current_day_number - $start_day_number, 7);
 }