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


PHP Carbon::formatLocalized方法代码示例

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


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

示例1: getFilters

 /**
  * Dodatkowe filtry Twig zwiazane z formatowaniem danych uzytkownika
  *
  * @return array
  */
 public function getFilters()
 {
     return [new Twig_SimpleFilter('format_date', function ($dateTime, $diffForHumans = true) {
         $format = Auth::check() ? auth()->user()->date_format : '%Y-%m-%d %H:%M';
         if (!$dateTime instanceof Carbon) {
             $dateTime = new Carbon($dateTime);
         }
         $now = Carbon::now();
         if (!$diffForHumans) {
             return $dateTime->formatLocalized($format);
         } elseif ($dateTime->diffInHours($now) < 1) {
             return $dateTime->diffForHumans(null, true) . ' temu';
         } elseif ($dateTime->isToday()) {
             return 'dziś, ' . $dateTime->format('H:i');
         } elseif ($dateTime->isYesterday()) {
             return 'wczoraj, ' . $dateTime->format('H:i');
         } else {
             return $dateTime->formatLocalized($format);
         }
     }), new Twig_SimpleFilter('timestamp', function ($dateTime) {
         if ($dateTime instanceof Carbon) {
             return $dateTime->getTimestamp();
         } else {
             return strtotime($dateTime);
         }
     })];
 }
开发者ID:furious-programming,项目名称:coyote,代码行数:32,代码来源:User.php

示例2: month

 /**
  * @param string $year
  * @param string $month
  *
  * @param bool   $shared
  *
  * @return \Illuminate\View\View
  */
 public function month($year = '2014', $month = '1', $shared = false)
 {
     $start = new Carbon($year . '-' . $month . '-01');
     $subTitle = trans('firefly.reportForMonth', ['month' => $start->formatLocalized($this->monthFormat)]);
     $subTitleIcon = 'fa-calendar';
     $end = clone $start;
     $incomeTopLength = 8;
     $expenseTopLength = 8;
     if ($shared == 'shared') {
         $shared = true;
         $subTitle = trans('firefly.reportForMonthShared', ['month' => $start->formatLocalized($this->monthFormat)]);
     }
     $end->endOfMonth();
     $accounts = $this->helper->getAccountReport($start, $end, $shared);
     $incomes = $this->helper->getIncomeReport($start, $end, $shared);
     $expenses = $this->helper->getExpenseReport($start, $end, $shared);
     $budgets = $this->helper->getBudgetReport($start, $end, $shared);
     $categories = $this->helper->getCategoryReport($start, $end, $shared);
     $balance = $this->helper->getBalanceReport($start, $end, $shared);
     $bills = $this->helper->getBillReport($start, $end);
     Session::flash('gaEventCategory', 'report');
     Session::flash('gaEventAction', 'month');
     Session::flash('gaEventLabel', $start->format('F Y'));
     return view('reports.month', compact('start', 'shared', 'subTitle', 'subTitleIcon', 'accounts', 'incomes', 'incomeTopLength', 'expenses', 'expenseTopLength', 'budgets', 'balance', 'categories', 'bills'));
 }
开发者ID:zetaron,项目名称:firefly-iii,代码行数:33,代码来源:ReportController.php

示例3: formatLocalized

 public function formatLocalized($format = self::COOKIE)
 {
     if (strpos($format, '%f') !== false) {
         $langKey = strtolower(parent::format("F"));
         $replace = \Lang::get("localized-carbon::months." . $langKey);
         $result = str_replace('%f', $replace, $format);
     } else {
         $result = $format;
     }
     $result = parent::formatLocalized($result);
     return $result;
 }
开发者ID:justclimber,项目名称:localized-carbon,代码行数:12,代码来源:LocalizedCarbon.php

示例4: history

 /**
  * @param Collection $set
  *
  * @return array
  */
 public function history(Collection $set) : array
 {
     // language:
     $format = (string) trans('config.month_and_day');
     $data = ['count' => 1, 'labels' => [], 'datasets' => [['label' => 'Diff', 'data' => []]]];
     $sum = '0';
     foreach ($set as $key => $value) {
         $date = new Carbon($key);
         $sum = bcadd($sum, $value);
         $data['labels'][] = $date->formatLocalized($format);
         $data['datasets'][0]['data'][] = round($sum, 2);
     }
     return $data;
 }
开发者ID:roberthorlings,项目名称:firefly-iii,代码行数:19,代码来源:ChartJsPiggyBankChartGenerator.php

示例5: history

 /**
  * @param Collection $set
  *
  * @return array
  */
 public function history(Collection $set)
 {
     // language:
     $format = trans('config.month_and_day');
     $data = ['count' => 1, 'labels' => [], 'datasets' => [['label' => 'Diff', 'data' => []]]];
     $sum = '0';
     bcscale(2);
     foreach ($set as $entry) {
         $date = new Carbon($entry->date);
         $sum = bcadd($sum, $entry->sum);
         $data['labels'][] = $date->formatLocalized($format);
         $data['datasets'][0]['data'][] = round($sum, 2);
     }
     return $data;
 }
开发者ID:webenhanced,项目名称:firefly-iii,代码行数:20,代码来源:ChartJsPiggyBankChartGenerator.php

示例6: history

 /**
  * @param Collection $set
  *
  * @return array
  */
 public function history(Collection $set)
 {
     // language:
     $language = Preferences::get('language', 'en')->data;
     $format = Config::get('firefly.month.' . $language);
     $data = ['count' => 1, 'labels' => [], 'datasets' => [['label' => 'Diff', 'data' => []]]];
     $sum = '0';
     bcscale(2);
     foreach ($set as $entry) {
         $date = new Carbon($entry->date);
         $sum = bcadd($sum, $entry->sum);
         $data['labels'][] = $date->formatLocalized($format);
         $data['datasets'][0]['data'][] = round($sum, 2);
     }
     return $data;
 }
开发者ID:ebbz,项目名称:firefly-iii,代码行数:21,代码来源:ChartJsPiggyBankChartGenerator.php

示例7: report

 /**
  * @param string     $reportType
  * @param Carbon     $start
  * @param Carbon     $end
  * @param Collection $accounts
  *
  * @return View
  * @throws FireflyException
  */
 public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts)
 {
     $this->createRepositories();
     // throw an error if necessary.
     if ($end < $start) {
         throw new FireflyException('End date cannot be before start date, silly!');
     }
     // lower threshold
     if ($start < session('first')) {
         $start = session('first');
     }
     View::share('subTitle', trans('firefly.report_' . $reportType, ['start' => $start->formatLocalized($this->monthFormat), 'end' => $end->formatLocalized($this->monthFormat)]));
     View::share('subTitleIcon', 'fa-calendar');
     switch ($reportType) {
         default:
             throw new FireflyException('Unfortunately, reports of the type "' . e($reportType) . '" are not yet available. ');
         case 'default':
             // more than one year date difference means year report.
             if ($start->diffInMonths($end) > 12) {
                 return $this->defaultMultiYear($reportType, $start, $end, $accounts);
             }
             // more than two months date difference means year report.
             if ($start->diffInMonths($end) > 1) {
                 return $this->defaultYear($reportType, $start, $end, $accounts);
             }
             // otherwise default
             return $this->defaultMonth($reportType, $start, $end, $accounts);
         case 'audit':
             // always default
             return $this->auditReport($start, $end, $accounts);
     }
 }
开发者ID:roberthorlings,项目名称:firefly-iii,代码行数:41,代码来源:ReportController.php

示例8: timestamp

 public function timestamp(Carbon $date, $format = '%x %X')
 {
     return $date->formatLocalized($format);
 }
开发者ID:jeroennoten,项目名称:laravel-format,代码行数:4,代码来源:Format.php

示例9: report

 /**
  * @param            $reportType
  * @param Carbon     $start
  * @param Carbon     $end
  * @param Collection $accounts
  *
  * @return View
  */
 public function report($reportType, Carbon $start, Carbon $end, Collection $accounts)
 {
     // throw an error if necessary.
     if ($end < $start) {
         return view('error')->with('message', 'End date cannot be before start date, silly!');
     }
     // lower threshold
     if ($start < Session::get('first')) {
         $start = Session::get('first');
     }
     switch ($reportType) {
         default:
         case 'default':
             View::share('subTitle', trans('firefly.report_default', ['start' => $start->formatLocalized($this->monthFormat), 'end' => $end->formatLocalized($this->monthFormat)]));
             View::share('subTitleIcon', 'fa-calendar');
             // more than one year date difference means year report.
             if ($start->diffInMonths($end) > 12) {
                 return $this->defaultMultiYear($reportType, $start, $end, $accounts);
             }
             // more than two months date difference means year report.
             if ($start->diffInMonths($end) > 1) {
                 return $this->defaultYear($reportType, $start, $end, $accounts);
             }
             return $this->defaultMonth($reportType, $start, $end, $accounts);
     }
 }
开发者ID:webenhanced,项目名称:firefly-iii,代码行数:34,代码来源:ReportController.php

示例10: createYearHeaders

 /**
  * @param Carbon $current
  * @param Carbon $end
  *
  * @return array
  */
 private function createYearHeaders(Carbon $current, Carbon $end) : array
 {
     $headers = [];
     while ($current < $end) {
         $short = $current->format('m-Y');
         $headers[$short] = $current->formatLocalized((string) trans('config.month'));
         $current->addMonth();
     }
     return $headers;
 }
开发者ID:roberthorlings,项目名称:firefly-iii,代码行数:16,代码来源:BudgetReportHelper.php

示例11: periodShow

 /**
  * @param \Carbon\Carbon $date
  * @param                $repeatFrequency
  *
  * @return string
  * @throws FireflyException
  */
 public function periodShow(Carbon $date, $repeatFrequency)
 {
     $formatMap = ['daily' => '%e %B %Y', 'week' => 'Week %W, %Y', 'weekly' => 'Week %W, %Y', 'quarter' => '%B %Y', 'month' => '%B %Y', 'monthly' => '%B %Y', 'year' => '%Y', 'yearly' => '%Y'];
     if (isset($formatMap[$repeatFrequency])) {
         return $date->formatLocalized($formatMap[$repeatFrequency]);
     }
     throw new FireflyException('No date formats for frequency "' . $repeatFrequency . '"!');
 }
开发者ID:RonaldvanMeer,项目名称:firefly-iii,代码行数:15,代码来源:Navigation.php

示例12: periodShow

 /**
  * @param \Carbon\Carbon $date
  * @param                $repeatFrequency
  *
  * @return string
  * @throws FireflyException
  */
 public function periodShow(Carbon $date, string $repeatFrequency) : string
 {
     $formatMap = ['1D' => trans('config.specific_day'), 'daily' => trans('config.specific_day'), 'custom' => trans('config.specific_day'), '1W' => trans('config.week_in_year'), 'week' => trans('config.week_in_year'), 'weekly' => trans('config.week_in_year'), '3M' => trans('config.quarter_of_year'), 'quarter' => trans('config.quarter_of_year'), '1M' => trans('config.month'), 'month' => trans('config.month'), 'monthly' => trans('config.month'), '1Y' => trans('config.year'), 'year' => trans('config.year'), 'yearly' => trans('config.year'), '6M' => trans('config.half_year')];
     if (isset($formatMap[$repeatFrequency])) {
         return $date->formatLocalized(strval($formatMap[$repeatFrequency]));
     }
     throw new FireflyException('No date formats for frequency "' . $repeatFrequency . '"!');
 }
开发者ID:roberthorlings,项目名称:firefly-iii,代码行数:15,代码来源:Navigation.php

示例13: getMonthName

 /**
  *
  * Returns localized month name
  *
  * @param string $date
  * @return string
  */
 protected function getMonthName($date = '')
 {
     $d = new Carbon($date);
     return $d->formatLocalized('%B');
 }
开发者ID:graker,项目名称:blogarchive,代码行数:12,代码来源:BlogArchive.php

示例14: getPostedOnAttribute

 public function getPostedOnAttribute($date)
 {
     $new_date = new Carbon($date);
     return $new_date->formatLocalized('%A %d, %B %Y at %H:%M:%S');
 }
开发者ID:Gabriel-aa,项目名称:curso-laravel-express,代码行数:5,代码来源:Post.php


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