当前位置: 首页>>代码示例>>PHP>>正文


PHP Carbon::eq方法代码示例

本文整理汇总了PHP中Carbon\Carbon::eq方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::eq方法的具体用法?PHP Carbon::eq怎么用?PHP Carbon::eq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Carbon\Carbon的用法示例。


在下文中一共展示了Carbon::eq方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: computeStockOnHand

 /**
  * Compute stock on hand
  * @param unknown $currentRnum
  * @param unknown $previousRnum
  * @return multitype:|multitype:number Ambigous <string, number>
  */
 public function computeStockOnHand($currentRnum, $previousRnum = null)
 {
     $currentReplenish = ModelFactory::getInstance('TxnReplenishmentHeader')->with('salesman', 'details')->where('reference_number', $currentRnum)->first();
     $previousReplenish = '';
     if ($previousRnum) {
         $previousReplenish = ModelFactory::getInstance('StockOnHand')->with('items')->where('replenishment_number', $previousRnum)->first();
     }
     if (!$currentReplenish) {
         return false;
     }
     $stockOnHand = [];
     $to = new Carbon($currentReplenish->replenishment_date);
     $goLive = new Carbon(config('system.go_live_date'));
     //Replenishment
     if ($previousReplenish) {
         foreach ($previousReplenish->items as $item) {
             if (!isset($stockOnHand[$item->item_code])) {
                 $stockOnHand[$item->item_code] = 0;
             }
             $stockOnHand[$item->item_code] += $item->quantity;
         }
         $from = (new Carbon($previousReplenish->stock_date))->addDay();
     } else {
         foreach ($currentReplenish->details as $item) {
             if (!isset($stockOnHand[$item->item_code])) {
                 $stockOnHand[$item->item_code] = 0;
             }
             $stockOnHand[$item->item_code] += $item->quantity;
         }
         $from = new Carbon($to);
     }
     $salesmanCode = $currentReplenish->salesman->salesman_code;
     $dates = [];
     while ($from->lte($to)) {
         $date = $from->format('Y-m-d');
         $stockTransfers = ModelFactory::getInstance('TxnStockTransferInHeader')->with('details')->where(\DB::raw('DATE(transfer_date)'), $date)->where('salesman_code', $salesmanCode)->orderBy('transfer_date')->get();
         // Stock Transfer
         $stockTransferItemCount = [];
         if ($stockTransfers) {
             foreach ($stockTransfers as $stock) {
                 foreach ($stock->details as $item) {
                     if (!isset($stockOnHand[$item->item_code])) {
                         $stockOnHand[$item->item_code] = 0;
                     }
                     $stockOnHand[$item->item_code] += $item->quantity;
                 }
             }
         }
         $sales = ModelFactory::getInstance('TxnSalesOrderHeader')->with('details', 'customer')->where(\DB::raw('DATE(so_date)'), $date)->where('salesman_code', $salesmanCode)->orderBy('so_date')->get();
         // Sales Invoice
         $salesItemCount = [];
         if ($sales) {
             foreach ($sales as $sale) {
                 foreach ($sale->details as $item) {
                     if (!isset($stockOnHand[$item->item_code])) {
                         $stockOnHand[$item->item_code] = 0;
                     }
                     if (false !== strpos($sale->customer->customer_name, '_Van to Warehouse')) {
                         $stockOnHand[$item->item_code] -= $item->order_qty;
                     } elseif (false !== strpos($sale->customer->customer_name, '_Adjustment')) {
                         $stockOnHand[$item->item_code] -= $item->order_qty;
                     } else {
                         $stockOnHand[$item->item_code] -= $item->quantity;
                     }
                 }
             }
         }
         $returns = ModelFactory::getInstance('TxnReturnHeader')->with('details', 'customer')->where(\DB::raw('DATE(return_date)'), $date)->where('salesman_code', $salesmanCode)->orderBy('return_date')->get();
         // Returns Invoice
         $returnsItemCount = [];
         if ($returns) {
             foreach ($returns as $return) {
                 foreach ($return->details as $item) {
                     if (!isset($stockOnHand[$item->item_code])) {
                         $stockOnHand[$item->item_code] = 0;
                     }
                     $stockOnHand[$item->item_code] += $item->quantity;
                 }
             }
         }
         if ($from->eq($to)) {
             foreach ($currentReplenish->details as $item) {
                 if (!isset($stockOnHand[$item->item_code])) {
                     $stockOnHand[$item->item_code] = 0;
                 }
                 $stockOnHand[$item->item_code] -= $item->quantity;
             }
         }
         $stock = ModelFactory::getInstance('StockOnHand');
         if ($from->eq($to)) {
             $stock->replenishment_number = $currentReplenish->reference_number;
         } else {
             $stock->replenishment_number = $previousReplenish ? $previousReplenish->replenishment_number : $currentReplenish->reference_number;
         }
//.........这里部分代码省略.........
开发者ID:atudz,项目名称:SFAReport,代码行数:101,代码来源:ReportsPresenter.php

示例2: displayRange

 /**
  * @param Carbon $start
  * @param Carbon $end
  */
 public static function displayRange(Carbon $start, Carbon $end)
 {
     if ($start->eq($end)) {
         return $end->format('F j, Y');
     }
     if ($start->year != $end->year) {
         return $start->format('F j, Y') . ' - ' . $end->format('F j, Y');
     }
     if ($start->month != $end->month) {
         return $start->format('F j') . ' - ' . $end->format('F j, Y');
     }
     return $start->format('F j') . ' - ' . $end->format('j, Y');
 }
开发者ID:jasonmccreary,项目名称:courses.e-hazard.com,代码行数:17,代码来源:DateHelper.php

示例3: isExcluded

 /**
  * Determine if a date is a non-business day
  *
  * @param Carbon $dt
  * @return bool
  */
 public function isExcluded(Carbon $dt)
 {
     foreach ($this->exclusions() as $exc) {
         if ($dt->eq($exc)) {
             return TRUE;
         }
     }
     foreach ($this->callbacks() as $fn) {
         if ($fn($dt) == TRUE) {
             return TRUE;
         }
     }
     return FALSE;
 }
开发者ID:rovangju,项目名称:carbon-nbd,代码行数:20,代码来源:Calculator.php

示例4: filter

 /**
  * Datetime exact match check as well as between check
  * @param string $content
  * @param string $search
  * @param string $type
  * @return bool
  */
 public function filter($content, $search, $type)
 {
     $search = is_array($search) ? $search : [$search];
     $search = array_map(function ($searchValue) {
         return is_a($searchValue, Carbon::class) ? $searchValue : new Carbon($searchValue);
     }, $search);
     $current = new Carbon($content);
     switch ($type) {
         case 'in':
             return $current->gte($search[0]) && $current->lt($search[1]);
             break;
         default:
             return $current->eq($search[0]);
     }
 }
开发者ID:web-feet,项目名称:coasterframework,代码行数:22,代码来源:Datetime.php

示例5: ignoreNDOW

 /**
  * Exclude a more complicated method for something like a holiday, e.g.: Memorial Day - "Last Monday in May"
  * this could be solved using CoreCallbacks::ignoreNDOW(5, -1, 1) 
  * 
  * @param integer $month 1 based index of month, 1 = Jan, 12 = dec
  * @param integer $nth Ignore the "nth" $dayOfWeek of the given month (1-6, To get 'LAST' $dayOfWeek, use -1)
  * @param integer $dayOfWeek Zero based index day of the week - 0 = Sunday, 6 = Saturday
  *
  * @return callable
  */
 public static function ignoreNDOW($month, $nth, $dayOfWeek)
 {
     return function (Carbon $context) use($month, $nth, $dayOfWeek) {
         if ($context->month !== $month) {
             return FALSE;
         }
         $cmp = new Carbon($context->format('Y-m-') . '01');
         /* Set our walker up to the first of the context's month */
         $ticks = 0;
         /**
          * @var $stack Carbon[]
          */
         $stack = array();
         /* Used to track 'nth' */
         for ($i = 0; $i < $context->daysInMonth; $i++) {
             if ($cmp->dayOfWeek == $dayOfWeek) {
                 $stack[] = clone $cmp;
                 $ticks++;
                 if ($cmp->eq($context)) {
                     /* "FIRST" or generic 'nth' */
                     if ($nth == $ticks) {
                         return TRUE;
                     }
                 }
             }
             $cmp->addDay();
         }
         /* For brevity, checking for the -1 anyways */
         if ($nth == -1) {
             /**
              * @var $last Carbon
              */
             $last = array_pop($stack);
             return $last->eq($context);
         }
         return FALSE;
     };
 }
开发者ID:rovangju,项目名称:carbon-nbd,代码行数:48,代码来源:CoreCallbacks.php


注:本文中的Carbon\Carbon::eq方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。