Example #1
1
 /**
  * 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);
         }
     })];
 }
Example #2
0
 public static function formatHistory($val)
 {
     $time = new Carbon($val);
     $now = Carbon::now();
     if ($time->isToday() == $now->isToday()) {
         return 'Today at ' . $val->format('H:i');
     } elseif ($time->isYesterday()) {
         return 'Yesterday at ' . $val->format('H:i');
     } elseif ($time->format('Y') == $now->format('Y')) {
         return $val->format('d M, H:i');
     } elseif ($time->format('Y') != $now->format('Y')) {
         return $val->format('d M Y, H:i');
     }
 }
function ivy_echo_date(\Carbon\Carbon $date)
{
    $date->setTimezone(config('params.user_timezone'));
    return $date->isToday() ? 'Mới @' . $date->format(config('params.user_hourformat')) : ($date->isYesterday() ? 'Hôm qua @' . $date->format(config('params.user_hourformat')) : $date->format(config('params.user_dateformat')));
}
Example #4
0
printf("difference between now and %s in \n\thours: %d, \n\tdays: %d, \n\tweeks: %d, \n\tweekend days: %d, \n\tweek days: %s, \n\thuman readable: %s\n", $septEighteen2014->toFormattedDateString(), $dtBerlin->diffInHours($septEighteen2014), $dtBerlin->diffInDays($septEighteen2014), $dtBerlin->diffInWeeks($septEighteen2014), $dtBerlin->diffInWeekendDays($septEighteen2014), $dtBerlin->diffInWeekDays($septEighteen2014), $dtBerlin->diffForHumans($septEighteen2014));
// Date formatting
echo $dtBerlin->toDateString() . "\n";
echo $dtBerlin->toFormattedDateString() . "\n";
echo $dtBerlin->toTimeString() . "\n";
echo $dtBerlin->toDateTimeString() . "\n";
echo $dtBerlin->toDayDateTimeString() . "\n";
echo $dtBerlin->toRfc1036String() . "\n";
echo $dtBerlin->toAtomString() . "\n";
echo $dtBerlin->toCookieString() . "\n";
echo $dtBerlin->toRssString() . "\n";
$dtBerlin->setToStringFormat('l jS \\of F Y');
echo $dtBerlin . "\n";
echo (int) $dtBerlin->isLeapYear() . "\n";
// is* range of functions test
printf("Is yesterday? %s\n", $dtBerlin->isYesterday() ? "yes" : "no");
printf("Is a Thursday? %s\n", $dtBerlin->isThursday() ? "yes" : "no");
printf("Is in the future? %s\n", $dtBerlin->isFuture() ? "yes" : "no");
printf("Is a leap year? %s\n", $dtBerlin->isLeapYear() ? "yes" : "no");
// first and last of the month
printf("First of the month %s\n", $dtBerlin->firstOfMonth());
printf("Last of the month %s\n", $dtBerlin->lastOfMonth());
// nthOf* function test
printf("Start of the month %s\n", $dtBerlin->startOfMonth());
printf("End of the month %s\n", $dtBerlin->endOfMonth());
printf("End of the decade %s\n", $dtBerlin->endOfDecade());
// Date manipulation
print $dtBerlin->addHours(5)->addDays(2)->addWeeks(1)->addMonths(3);
print $dtBerlin->subMonths(8)->subHours(7);
// Find UK Bank Holidays
$dtLondon = CitcoCarbon::today('Europe/London');
Example #5
0
printf("difference between now and %s in \n\thours: %d, \n\tdays: %d, \n\tweeks: %d, \n\tweekend days: %d, \n\tweek days: %s, \n\thuman readable: %s\n", $septEighteen2014->toFormattedDateString(), $dtBerlin->diffInHours($septEighteen2014), $dtBerlin->diffInDays($septEighteen2014), $dtBerlin->diffInWeeks($septEighteen2014), $dtBerlin->diffInWeekendDays($septEighteen2014), $dtBerlin->diffInWeekDays($septEighteen2014), $dtBerlin->diffForHumans($septEighteen2014));
// Date formatting
echo $dtBerlin->toDateString() . "\n";
echo $dtBerlin->toFormattedDateString() . "\n";
echo $dtBerlin->toTimeString() . "\n";
echo $dtBerlin->toDateTimeString() . "\n";
echo $dtBerlin->toDayDateTimeString() . "\n";
echo $dtBerlin->toRfc1036String() . "\n";
echo $dtBerlin->toAtomString() . "\n";
echo $dtBerlin->toCookieString() . "\n";
echo $dtBerlin->toRssString() . "\n";
$dtBerlin->setToStringFormat('l jS \\of F Y');
echo $dtBerlin . "\n";
echo (int) $dtBerlin->isLeapYear() . "\n";
// is* range of functions test
echo "Is yesterday? " . ($dtBerlin->isYesterday() ? "yes" : "no") . PHP_EOL;
echo "Is a Thursday? " . ($dtBerlin->isThursday() ? "yes" : "no") . PHP_EOL;
echo "Is in the future? " . ($dtBerlin->isFuture() ? "yes" : "no") . PHP_EOL;
echo "Is a leap year? " . ($dtBerlin->isLeapYear() ? "yes" : "no") . PHP_EOL;
// first and last of the month
echo "First of the month " . $dtBerlin->firstOfMonth() . PHP_EOL;
echo "Last of the month " . $dtBerlin->lastOfMonth() . PHP_EOL;
// nthOf* function test
echo "Start of the month ", $dtBerlin->startOfMonth() . PHP_EOL;
echo "End of the month ", $dtBerlin->endOfMonth() . PHP_EOL;
echo "End of the decade ", $dtBerlin->endOfDecade() . PHP_EOL;
// Date manipulation
echo $dtBerlin->addHours(5)->addDays(2)->addWeeks(1)->addMonths(3) . PHP_EOL;
echo $dtBerlin->subMonths(8)->subHours(7) . PHP_EOL;
// Find UK Bank Holidays
$dtLondon = CitcoCarbon::today('Europe/London');
Example #6
0
    ?>
                    
        @foreach ( $events as $key => $value )
            <div class="list-group-item disabled">
                <span class="text-uppercase">
                    <?php 
    $dt = new Carbon($key);
    ?>
                    <?php 
    if ($dt->isToday()) {
        echo "<strong>hoje</strong>, " . strftime("%A %d de %B", strtotime($key));
    } else {
        if ($dt->isTomorrow()) {
            echo "<strong>amanhã</strong>, " . strftime("%A %d de %B", strtotime($key));
        } else {
            if ($dt->isYesterday()) {
                echo "<strong>ontem</strong>, " . strftime("%A %d de %B", strtotime($key));
            } else {
                echo strftime("%A, %d de %B", strtotime($key));
            }
        }
    }
    ?>
                </span>
            </div>
            @foreach ( $value as $event )

                <?php 
    if ("Tarefa" == get_class($event)) {
        ?>
                    @include('tarefas.panels.item',array('tarefa'=>$event))