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


PHP Carbon::copy方法代码示例

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


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

示例1: scopeWeek

 /**
  * Get events by week.
  *
  * @param   QueryBuilder  $query
  * @param   Carbon|int    $year  Year or date
  * @param   int           $week  Week number if year is int
  * @return  QueryBuilder
  *
  * @throws  ApplicationException  on missing parameters
  */
 public function scopeWeek($query, $year, $week = null)
 {
     if ($year instanceof Carbon) {
         $from = $year->copy()->startOfWeek();
     } else {
         if ($week) {
             $from = Carbon::create($year, 1, 1)->startOfWeek();
             // Is the first day of the year on a week of last year?
             if ($from->weekOfYear != 1) {
                 $from->addWeek();
             }
             if ($week > 1) {
                 $from->addWeeks($week - 1);
             }
         } else {
             throw new ApplicationException('Week missing');
         }
     }
     return $this->scopeBetween($query, $from, $from->copy()->endOfWeek());
 }
开发者ID:anqqa,项目名称:klubitus-octobercms-plugins,代码行数:30,代码来源:Event.php

示例2: getTransactionsByMember

 public function getTransactionsByMember(Corporation $corp, array $member_ids, Carbon $date)
 {
     $start = $date->copy();
     $start->subMonth()->setTime(0, 0, 0);
     $end = $date->copy();
     $end->setTime(23, 59, 59);
     $sql = 'SELECT jt.owner_id2, group_concat(DISTINCT jt.id) as ids
         FROM journal_transactions as jt
         LEFT JOIN accounts as acc on jt.account_id=acc.id
         WHERE  acc.corporation_id = :corp_id
         AND jt.owner_id2 in ( :owner_ids )
         AND jt.date >= :start_date
         AND jt.date <= :end_date
         GROUP BY jt.owner_id2';
     $rsm = new ResultSetMappingBuilder($this->getEntityManager());
     $rsm->addRootEntityFromClassMetadata('AppBundle\\Entity\\JournalTransaction', 'jt');
     $rsm->addFieldResult('jt', 'owner_id2', 'owner_id2');
     $rsm->addFieldResult('jt', 'ids', 'id');
     $q = $this->getEntityManager()->createNativeQuery($sql, $rsm);
     $q->setParameter('corp_id', $corp->getId());
     $q->setParameter('owner_ids', $member_ids, Connection::PARAM_INT_ARRAY);
     $q->setParameter('start_date', $start);
     $q->setParameter('end_date', $end);
     $results = $q->getResult();
     $real_res = [];
     foreach ($results as $res) {
         $ids = explode(',', $res->getId());
         $rt = $this->createQueryBuilder('jt')->select('sum(jt.amount) as total_amount')->where('jt.id in (:j_ids)')->setParameter('j_ids', $ids)->getQuery()->getResult();
         $r = $this->createQueryBuilder('jt')->select('jt')->where('jt.id in (:j_ids)')->setParameter('j_ids', $ids)->getQuery()->getResult();
         $real_res[] = ['user' => $res->getOwnerId2(), 'total' => $rt, 'orig_ids' => $r];
     }
     return $real_res;
 }
开发者ID:Remnant-Legion,项目名称:eau,代码行数:33,代码来源:JournalTransactionRepository.php

示例3: updateFromSalesforceRefresh

 public function updateFromSalesforceRefresh(array $salesforceToken)
 {
     $this->dateIssued = Carbon::createFromTimestamp((int) ($salesforceToken['issued_at'] / 1000));
     $this->dateExpires = $this->dateIssued->copy()->addHour()->subMinutes(5);
     $this->signature = $salesforceToken['signature'];
     $this->accessToken = $salesforceToken['access_token'];
 }
开发者ID:voronoy,项目名称:salesforce-api-php-wrapper,代码行数:7,代码来源:AccessToken.php

示例4: getYulePartyDate

 /**
  * Return the next yule party date
  *
  * @return Carbon
  */
 public function getYulePartyDate()
 {
     $potentialDate = $this->fromDateToYuleDate($this->date->copy()->month(12)->day(1)->hour(15)->minute(0)->second(0));
     if ($this->strict || $potentialDate->isSameDay($this->date) || $potentialDate->gte($this->date)) {
         return $potentialDate;
     }
     return $this->fromDateToYuleDate($this->date->copy()->addYear(1)->month(12)->day(1)->hour(15)->minute(0)->second(0));
 }
开发者ID:PuppetmasterDK,项目名称:yule-party,代码行数:13,代码来源:YuleDate.php

示例5: getEventsStatByCardNumberAndDate

 public function getEventsStatByCardNumberAndDate($cardNumber, Carbon $date)
 {
     $firstDayOfMonth = $date->copy()->startOfMonth();
     $endDayOfMonth = $date->copy()->endOfMonth();
     $events = $this->getEventsBetweenDatesAndCardNumber($cardNumber, $firstDayOfMonth, $endDayOfMonth);
     $eventSummaryByDate = $this->groupEventsByDayDate($events);
     $eventsSummaryByDateWithTime = $this->eventsSummarizeByDateWithTime($eventSummaryByDate);
     $dayStats = $this->mixWithMonthDays($eventsSummaryByDateWithTime, $firstDayOfMonth, $endDayOfMonth);
     return $dayStats;
 }
开发者ID:sasik-github,项目名称:system.pro,代码行数:10,代码来源:EventRepository.php

示例6: generateYearCalendar

 /**
  * Generates a year calendar array for front end usage
  *
  * @param array $marked for the dates to mark
  * @return array
  */
 public function generateYearCalendar(array $marked = [])
 {
     $calendar = [];
     $firstOfYear = $this->now->copy()->firstOfYear();
     $lastOfYear = $this->now->copy()->lastOfYear();
     while ($firstOfYear != $lastOfYear) {
         $day = ['carbon' => $firstOfYear->copy(), 'marked' => false];
         foreach ($marked as $mark) {
             /** @var Carbon $mark */
             if ($mark->isSameDay($day['carbon'])) {
                 $day['marked'] = true;
                 break;
             }
         }
         $calendar[$firstOfYear->month][] = $day;
         //increment day
         $firstOfYear->addDay();
     }
     //build out months => weeks => days
     $generated_year = ['year' => $this->now->year, 'months' => []];
     foreach ($calendar as $month => $days) {
         //add month
         $generated_year['months'][] = ['month' => ['month' => $month, 'year' => $this->now->year, 'pretty' => Carbon::create(null, $month)->format('F')], 'weeks' => []];
         //reset week index, month index
         $week_index = 0;
         foreach ($days as $day) {
             if ($day['carbon']->dayOfWeek == Carbon::MONDAY) {
                 $week_index++;
                 //add week
                 $generated_year['months'][$month - 1]['weeks'][$week_index] = ['days' => []];
             }
             if ($day['carbon']->day == 1) {
                 $pad = $day['carbon']->dayOfWeek - 1 >= 0 ? $day['carbon']->dayOfWeek - 1 : 6;
                 for ($p = $pad; $p > 0; $p--) {
                     //add empty days for start of week
                     $generated_year['months'][$month - 1]['weeks'][$week_index]['days'][] = false;
                 }
             }
             //add day
             $generated_year['months'][$month - 1]['weeks'][$week_index]['days'][] = ['day' => $day['carbon']->format('Y-m-d'), 'day_of_month' => $day['carbon']->day, 'marked' => $day['marked']];
         }
     }
     //add empty days at end of weeks with less than 7 days
     foreach ($calendar as $month => $days) {
         $month -= 1;
         foreach ($generated_year['months'][$month]['weeks'] as $week_index => $week) {
             # empty days to add
             $empty = 7 - count($week['days']);
             for ($e = $empty; $e > 0; $e--) {
                 $generated_year['months'][$month]['weeks'][$week_index]['days'][] = false;
             }
         }
     }
     return $generated_year;
 }
开发者ID:loganhenson,项目名称:calendar,代码行数:61,代码来源:Calendar.php

示例7: calculatePayDays

 /**
  *
  */
 public function calculatePayDays()
 {
     $result = [];
     $currentMonth = $this->startDate->copy();
     while ($currentMonth->lte($this->endDate) && $currentMonth->diffInMonths($this->endDate) >= 0) {
         $resultForCurrentMonth = ['month' => $currentMonth->copy()];
         $resultForCurrentMonth['salaryDate'] = $this->calculateSalaryDateByMonth($currentMonth->copy());
         $resultForCurrentMonth['bonusDate'] = $this->calculateBonusDateByMonth($currentMonth->copy());
         $currentMonth->addMonth();
         $result[] = $resultForCurrentMonth;
     }
     return $result;
 }
开发者ID:Oxyaction,项目名称:salary-calendar,代码行数:16,代码来源:SalaryCalendar.php

示例8: calcElements

 public function calcElements()
 {
     $this->calHeadings = [Lang::get('kurtjensen.mycalendar::lang.month.day_sun'), Lang::get('kurtjensen.mycalendar::lang.month.day_mon'), Lang::get('kurtjensen.mycalendar::lang.month.day_tue'), Lang::get('kurtjensen.mycalendar::lang.month.day_wed'), Lang::get('kurtjensen.mycalendar::lang.month.day_thu'), Lang::get('kurtjensen.mycalendar::lang.month.day_fri'), Lang::get('kurtjensen.mycalendar::lang.month.day_sat')];
     $time = new Carbon($this->month . '/1/' . $this->year);
     $time->copy();
     $this->monthTitle = $time->format('F');
     $this->monthNum = $time->month;
     $this->running_day = $time->dayOfWeek;
     $this->days_in_month = $time->daysInMonth;
     $this->dayPointer = 0 - $this->running_day;
     $prevMonthLastDay = $time->copy()->subMonth()->daysInMonth;
     $this->prevMonthMonday = $this->dayPointer + $prevMonthLastDay + 1;
     $this->linkNextMonth = $time->copy()->addDays(32);
     $this->linkPrevMonth = $time->copy()->subDays(2);
 }
开发者ID:ribsousa,项目名称:MyCalendar,代码行数:15,代码来源:Month.php

示例9: parseChannelChunk

 /**
  * @param Carbon $date
  * @param string $chunk
  * @return ChannelProgramming
  * @throws \Exception
  */
 private static function parseChannelChunk(Carbon $date, $chunk)
 {
     $res = new ChannelProgramming();
     $channelName = self::str_between_exclude($chunk, '<div class="tabla_topic">', '</div>');
     $channelName = trim(strip_tags($channelName));
     if (!$channelName) {
         throw new \Exception('parse error: no channel name');
     }
     $res->setChannelName($channelName);
     $content = self::str_between_exclude($chunk, '<ul class="prog_tabla">', '</ul>');
     if (!$content) {
         throw new \Exception('parse error: no content');
     }
     $content = str_replace('</li>', "\n", $content);
     $content = str_replace("\t", '', $content);
     $content = strip_tags($content);
     $programs = explode("\n", trim($content));
     $foundHour = 0;
     $addDays = 0;
     /** @var ChannelEvent $event */
     $event = null;
     foreach ($programs as $prog) {
         if (!$prog) {
             continue;
         }
         preg_match('/^(?<hh>[\\d]+)+\\:(?<mm>[\\d]+)+$/ui', $prog, $match);
         if (!empty($match['hh']) && !empty($match['mm'])) {
             $event = new ChannelEvent();
             $time = explode(' ', $prog)[0];
             $timeParts = explode(':', $time);
             if ($timeParts[0] < $foundHour) {
                 // new day
                 $addDays = 1;
             }
             $foundHour = $timeParts[0];
             $event->starts_at = $date->copy();
             $event->starts_at->addDays($addDays);
             $event->starts_at->hour = $timeParts[0];
             $event->starts_at->minute = $timeParts[1];
             continue;
         }
         if (!$event) {
             continue;
         }
         $event->title = $prog;
         $res->addEvent($event);
     }
     // guesstimate end time for each event
     $events = $res->getEvents();
     for ($i = 0; $i < count($events); $i++) {
         if (!empty($events[$i + 1])) {
             $events[$i]->ends_at = $events[$i + 1]->starts_at->copy();
         } else {
             // HACK: we dont know end of last event, so we add 2 hours
             $events[$i]->ends_at = $events[$i]->starts_at->copy()->addHours(2);
         }
     }
     $res->setEvents($events);
     return $res;
 }
开发者ID:martinlindhe,项目名称:php-tvnu,代码行数:66,代码来源:Parser.php

示例10: getDeletedAt

 /**
  * @return null|Carbon
  */
 public function getDeletedAt()
 {
     if ($this->deletedAt === null) {
         return null;
     }
     return $this->deletedAt->copy();
 }
开发者ID:Zn4rK,项目名称:laravel-template,代码行数:10,代码来源:SoftDeletableDomainObject.php

示例11: getTotalByTypeDate

 protected function getTotalByTypeDate($type, Account $acc, Carbon $date)
 {
     $start = $date->copy();
     $start->setTime(0, 0, 0);
     $end = $start->copy();
     $end->setTime(23, 59, 59);
     return $this->createQueryBuilder('mt')->leftJoin('mt.account', 'acc')->where('acc = :acc')->andWhere('mt.date >= :start')->andWhere('mt.date <= :end')->andWhere('mt.transaction_type = :type')->setParameters(['acc' => $acc, 'start' => $start, 'end' => $end, 'type' => $type]);
 }
开发者ID:Covert-Inferno,项目名称:evetool,代码行数:8,代码来源:MarketTransactionRepository.php

示例12: calculateEventLength

 /**
  * Calculate event length in seconds
  *
  * @param array $data
  *
  * @return int
  */
 protected function calculateEventLength(array $data)
 {
     $start = $this->carbon->copy()->setTimestamp(strtotime($data['start']['date'] . ' ' . $data['start']['time']));
     if (array_key_exists('all_day', $data)) {
         $end = $this->carbon->copy()->setTimestamp(strtotime($data['start']['date'] . ' 23:59:59'));
     } else {
         $end = $this->carbon->copy()->setTimestamp(strtotime($data['start']['date'] . ' ' . $data['end']['time']));
     }
     return $start->diffInSeconds($end);
 }
开发者ID:todstoychev,项目名称:calendar-events,代码行数:17,代码来源:CalendarEventsEngine.php

示例13: zipOneDay

 public static function zipOneDay(Carbon $date)
 {
     $begin = $date->copy()->setTime(0, 0, 0);
     $end = $date->copy()->setTime(23, 59, 59);
     $deleteLocs = [];
     $videoLocs = [];
     $videos = Video::where('state', '=', 'downloaded')->where('updated_at', '>=', $begin->toDateTimeString())->where('updated_at', '<=', $end->toDateTimeString())->get();
     foreach ($videos as $video) {
         $deleteLocs[] = $video->location;
         $videoLocs[] = storage_path('app/' . $video->location);
         $video->state = 'zipped';
         $video->save();
     }
     $imageLocs = [];
     $images = Image::where('state', '=', 'downloaded')->where('updated_at', '>=', $begin->toDateTimeString())->where('updated_at', '<=', $end->toDateTimeString())->get();
     foreach ($images as $image) {
         $deleteLocs[] = $image->location;
         $imageLocs[] = storage_path('app/' . $image->location);
         $image->state = 'zipped';
         $image->save();
     }
     $locs = array_merge($videoLocs, $imageLocs);
     if (count($locs) == 0) {
         Log::info('TumblrZip : no file to be ziped.');
         return;
     }
     $zipName = $begin->toDateString() . '.zip';
     $zipLocs = 'zips/' . $zipName;
     $zippy = Zippy::load();
     $zippy->create(storage_path('app/' . $zipLocs), $locs);
     $zip = new Zip();
     $zip->state = 'ziped';
     $zip->error = '';
     $zip->name = $zipName;
     $zip->date = $begin->toDateString();
     $zip->size = number_format(Storage::size($zipLocs) / 1024.0 / 1024.0, 2) . 'MB';
     $zip->imageSize = count($imageLocs);
     $zip->videoSize = count($videoLocs);
     $zip->location = $zipLocs;
     $zip->save();
     Storage::delete($deleteLocs);
 }
开发者ID:roslairy,项目名称:tumfetch,代码行数:42,代码来源:TumblrZip.php

示例14: setLabel

 /**
  * Set label for line and bar charts
  *
  * @return Collection
  */
 private function setLabel()
 {
     // Copy the Carbon instance of start_date
     $iterate_date = $this->start_date->copy();
     $labels = collect();
     while ($iterate_date <= $this->end_date) {
         $labels->push($iterate_date->format('M d'));
         $iterate_date->addDay();
     }
     return $labels;
 }
开发者ID:henrytung,项目名称:Bodie-CRM,代码行数:16,代码来源:Chart.php

示例15: eachDayOfWeek

 /**
  * Set the internal iterator for day of week for the instance.
  *
  * @param $dayOfWeek
  * @param callable $callback
  * @return $this
  */
 public function eachDayOfWeek($dayOfWeek, \Closure $callback)
 {
     $start = $this->startDate->copy();
     if ($start->dayOfWeek !== $dayOfWeek) {
         $start->next($dayOfWeek);
     }
     if ($start < $this->endDate) {
         $period = new static($start, $this->endDate);
         $period->eachDays(CarbonDate::DAYS_PER_WEEK, function (CarbonPeriod $period) use($callback) {
             $callback(new static($period->start(), $period->start()->addDay()));
         });
     }
     return $this;
 }
开发者ID:asdf20122012,项目名称:carbon-period,代码行数:21,代码来源:CarbonPeriod.php


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