/** * Display a listing of the resource. * * @return Response */ public function home() { $lastNews = News::orderBy('id', 'desc')->first(); $lastNews->description = $this::text_humanized($lastNews->description); Date::setLocale('fr'); $date = new Date($lastNews->when); $lastNews->when = $date->format('l j F Y'); $lastNews->hour = $date->format('H:i'); return view('page/home', ['news' => $lastNews]); }
public function build() { $translator = $this->processor->getTranslator(); $html = ""; Date::setLocale($this->locale); if ($this->printStyles) { $html .= $this->getStylesHtml(); } $hidden = $this->isModal ? ' style="display:none;"' : ''; if ($this->printFrame) { $html .= '<div id="changemodal-wrapper"' . $hidden . '><div id="changemodal"' . $hidden . '><div id="changemodal-frame"><h1>' . $this->title . '</h1>'; if ($this->isModal) { $html .= '<i id="close-button" class="fa fa-times"></i>'; } } else { $html .= '<div id="changemodal">'; } $html .= '<div class="changelog">'; try { foreach ($this->processor->getVersions() as $version) { $html .= '<h2 id="' . $version->getVersion() . '"'; if ($version->isYanked()) { $html .= ' class="yanked" title="' . $translator->translateTo('This release has been yanked.') . '"'; } $html .= '>' . $version->getVersion() . '</h2>'; if ($version->isReleased() && $version->getReleaseDate() !== null) { $date = new Date($version->getReleaseDate()->getTimestamp()); $html .= '<h3 title="' . '">' . $date->ago(); if ($this->printDownloadLinks && !$version->isYanked()) { $html .= ' <a href="' . $version->getUrl() . '" target="_blank"><i class="fa fa-download"></i></a>'; } $html .= '</h3>'; } $html .= '<div class="version-wrapper">'; foreach ($version->getChanges() as $label => $changes) { $html .= '<ul class="' . $label . '">'; foreach ($changes as $change) { $html .= '<li data-label="' . ucfirst($translator->translateTo($label)) . '">' . $change . '</li>'; } $html .= '</ul>'; } $html .= '</div>'; } } catch (\Exception $e) { $html .= '<div class="alert alert-danger" style="text-align: center" role="alert">' . '<i class="fa fa-lg fa-exclamation-triangle"></i><br>' . '<b>Could not get Changelog!</b><br>' . 'Error: <em>' . $e->getMessage() . '</em>' . '</div>'; } $html .= '</div></div>'; if ($this->printFrame) { $html .= '</div>'; } if ($this->printScripts) { $html .= $this->getScriptsHtml(); } return $html; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $categories = ForumCategories::all(); $categorie = ForumCategories::where('slug', $id)->first(); foreach ($categorie->subjects as $subject) { Date::setLocale('fr'); $date = new Date($subject->created); $subject->when = $date->format('j F Y'); } return view('forum.categorie.show', ['categorie' => $categorie]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $sujet = ForumSubjects::where("id", $id)->first(); $categorie = ForumCategories::find($sujet->category); foreach ($sujet->messages as $message) { Date::setLocale('fr'); $date = new Date($message->created); $message->when = $date->format('j F Y'); $message->message = $this::text_humanized($message->message); $message->message = BBCode::parse($message->message); } return view('forum.sujets.show', ['categorie' => $categorie, "sujet" => $sujet]); }
/** * @covers ::convert */ public function testConvert() { $test1 = Converter::convert(Calends::create(0, 'unix')); $this->assertEquals(['start' => Date::createFromTimestamp(0), 'duration' => \Carbon\CarbonInterval::seconds(0), 'end' => Date::createFromTimestamp(0)], $test1); $test2 = Converter::convert(Calends::create(['start' => 0, 'end' => 86400], 'unix')); $this->assertEquals(['start' => Date::createFromTimestamp(0), 'duration' => \Carbon\CarbonInterval::seconds(86400), 'end' => Date::createFromTimestamp(86400)], $test2); }
public function testTranslatesDays() { $days = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); foreach ($this->languages as $language) { $translations = (include "src/lang/{$language}/date.php"); foreach ($days as $day) { $date = new Date($day); $date->setLocale($language); $this->assertTrue(isset($translations[$day])); $this->assertEquals($translations[$day], $date->format('l'), "Language: {$language}"); // Full $this->assertEquals(substr($translations[$day], 0, 3), $date->format('D'), "Language: {$language}"); // Short } } }
/** * Handle the report incident command. * * @param \CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand $command * * @return \CachetHQ\Cachet\Models\Incident */ public function handle(ReportIncidentCommand $command) { $data = ['name' => $command->name, 'status' => $command->status, 'message' => $command->message, 'visible' => $command->visible]; // Link with the component. if ($command->component_id) { $data['component_id'] = $command->component_id; } // The incident occurred at a different time. if ($command->incident_date) { $incidentDate = Date::createFromFormat('d/m/Y H:i', $command->incident_date, config('cachet.timezone'))->setTimezone(Config::get('app.timezone')); $data['created_at'] = $incidentDate; $data['updated_at'] = $incidentDate; } // Create the incident $incident = Incident::create($data); // Update the component. if ($command->component_id) { Component::find($command->component_id)->update(['status' => $command->component_status]); } // Notify subscribers. if ($command->notify) { event(new IncidentWasReportedEvent($incident)); } return $incident; }
/** * Display a listing of the resource. * * @return Response */ public function index() { Date::setLocale('th'); $user = Auth::user(); $jobapps = Jobapp::all(); return view('hr.jobapps.index', compact('jobapps', 'user')); }
public function getInsert() { //if(Input::old('tanggal')!="" and Input::old('nis')!="") { $siswa = \DB::table('t_siswa_tingkat')->where('nis', Input::old('nis'))->first(); if ($siswa == null) { \Session::flash('siswa_ilang', 'NIS tidak ditemukan'); return redirect('/home'); } $date = Date::createFromFormat('Y-m-d', Input::old('tanggal')); $tapel = AbsencesController::checkPeriode($date); $tapel['kd_tapel'] = \DB::table('t_tahun_ajaran')->where('tahun_ajaran', $tapel['tahun_ajaran'])->first()->kd_tahun_ajaran; $siswa_tingkat = \DB::table('t_siswa_tingkat')->where('nis', $siswa->nis)->where('kd_tahun_ajaran', $tapel['kd_tapel'])->where('kd_periode_belajar', $tapel['periode'])->first(); if ($siswa_tingkat == null) { \Session::flash('tahun_ajaran', 'Tahun ajaran belum dimulai'); return redirect('/home'); } $siswa = \DB::table('t_siswa')->where('nis', $siswa->nis)->first(); $pikets = \DB::table('t_piket')->where('hari', $date->format('l'))->first(); $piket = \DB::table('t_guru')->where('kd_guru', $pikets->kd_guru)->first(); $jam_masuk = Date::createFromFormat('H:i:s', $pikets->jam_masuk, Date::now()->tzName); return view('absences.insert', compact('date', 'jam_masuk', 'siswa', 'siswa_tingkat', 'piket', 'tapel')); //} //else // return redirect('home'); }
public function home() { $page_title = "لوحة التحكم"; $section_title = "لوحة التحكم"; Date::setLocale('ar'); $date = Date::now()->format('j F Y'); $day = Date::now()->format('l'); $month = Date::now()->format('F'); $year = Date::now()->format('Y'); //**************Tasks*************** $tasksToday = Task::orderBy('task_date', 'desc')->today()->take(5); $tasksWeek = Task::orderBy('task_date', 'desc')->thisweek()->take(5); $tasksMonth = Task::orderBy('task_date', 'desc')->thisMonth()->take(5); $tasks_count = count($tasksToday->toArray()); //**************Fails*************** $failsToday = Failure::orderBy('fail_time', 'desc')->today()->take(5); $failsWeek = Failure::orderBy('fail_time', 'desc')->thisweek()->take(5); $failsMonth = Failure::orderBy('fail_time', 'desc')->thisMonth()->take(5); $fails_count = count($failsToday->toArray()); //**************Repairs*************** $repairsToday = Repair::today(); $repairsWeek = Repair::thisweek(); $repairsMonth = Repair::thisMonth(); $repairs_count = count($repairsToday->toArray()); return view('dashboard.dashboard', compact('page_title', 'section_title', 'date', 'day', 'month', 'year', 'tasksToday', 'tasksMonth', 'tasksWeek', 'tasks_count', 'failsToday', 'failsMonth', 'failsWeek', 'fails_count', 'repairsToday', 'repairsMonth', 'repairsWeek', 'repairs_count')); }
public function convertToPHPValue($value, AbstractPlatform $platform) { $result = parent::convertToPHPValue($value, $platform); if ($result instanceof \DateTime) { return Date::instance($result); } return $result; }
/** * Handle the report maintenance command. * * @param \CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand $command * * @return \CachetHQ\Cachet\Models\Incident */ public function handle(ReportMaintenanceCommand $command) { $scheduledAt = Date::createFromFormat('d/m/Y H:i', $command->timestamp, config('cachet.timezone'))->setTimezone(Config::get('app.timezone')); $maintenanceEvent = Incident::create(['name' => $command->name, 'message' => $command->message, 'scheduled_at' => $scheduledAt, 'status' => 0, 'visible' => 1]); // Notify subscribers. event(new MaintenanceWasScheduledEvent($maintenanceEvent)); return $maintenanceEvent; }
private function showText($request) { $texts = Text::with('user', 'question')->where('question_id', $request->question_id)->get(['created_at', 'user_id', 'description', 'question_id']); foreach ($texts as $text) { $text['date'] = Date::parse($text->created_at)->diffForHumans(); } return ['text' => $texts]; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $album = Albums::find($id); $date = new Date('now', 'Europe/Brussels'); $date->month = $album->mois + 1; $album->mois = $date->format('F'); $proprietaire = User::find($album->ID_proprietaire); $album->proprietaire_nom = $proprietaire->first_name . ' ' . $proprietaire->last_name . ' (Propriétaire)'; $picturesData = $album->pictures; $pictures = array(); $i = 0; foreach ($picturesData as $picture) { $pictures[$i]['big'] = $picture->directory . '/' . $picture->name; $pictures[$i]['thumb'] = $picture->directory . '/thumb2_' . $picture->name; $i++; } return view('albums.show', compact('album', 'pictures')); }
function index(Request $request, $id) { if (auth()->user()->role_id == 3) { $plan = PlanProvider::where('provider_id', auth()->user()->provider->id)->orderBy('created_at', 'DESC')->first(); $finalPlan = new Date(); if ($plan) { $date = new Date($plan->created_at); $finalPlan = $date->addMonths($plan->period); } if (new Date() >= $finalPlan) { PlanProvider::create(['provider_id' => auth()->user()->provider->id, 'name' => $request->name, 'description' => $request->description, 'period' => $request->period, 'price' => $request->price]); return redirect()->route('inactivePlan'); } return redirect()->route('admin')->with(['message' => "Usted ya ha comprado un plan. Este finaliza el día {$finalPlan}"]); } else { return redirect()->route('admin')->with('messageError', 1); } }
/** * Returns date formatted according to given format. * @param string $format * @return string * @link http://php.net/manual/en/datetime.format.php */ public function format($format) { if (self::$jalali == false) { // dd(self::$jalali); } if (self::$jalali === true) { return $this->eDateTime->date($format, $this->getTimeStamp()); } return parent::format($format); }
public function renderHtml() { if ($this->_response) { $data = []; foreach ($this->_response as $tweet) { $data[] = ['userImage' => $tweet->user->profile_image_url, 'userName' => $tweet->user->name, 'created' => Date::parse($tweet->created_at)->ago(), 'text' => StrHelper::removeEmoji($tweet->text), 'source' => $tweet->source]; } return Application::getInstance()->jadeEngine()->render(Application::getInstance()->getBasePath() . '/frontend/src/jade/resource/twitter.jade', ['data' => $data]); } }
function today() { global $today; if (!isset($today)) { $today = Date::now(); $today->hour = 0; $today->minute = 0; $today->second = 0; } return $today; }
/** * Handle the report maintenance command. * * @param \CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand $command * * @return \CachetHQ\Cachet\Models\Incident */ public function handle(ReportMaintenanceCommand $command) { // TODO: Add validation to scheduledAt $scheduledAt = Date::createFromFormat('d/m/Y H:i', $command->timestamp, Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone')); $maintenanceEvent = Incident::create(['name' => $command->name, 'message' => $command->message, 'scheduled_at' => $scheduledAt, 'status' => 0, 'visible' => 1]); // Notify subscribers. if ($command->notify) { event(new MaintenanceWasScheduledEvent($maintenanceEvent)); } return $maintenanceEvent; }
private function reloadQuestions($id) { $questions = Question::where('product_id', $id)->orderBy('created_at', 'DESC')->get(); foreach ($questions as $question) { $question['texts'] = Text::with('user')->where('question_id', $question->id)->get(); foreach ($question->texts as $text) { $text['date'] = Date::parse($text->created_at)->diffForHumans(); } } return $questions; }
/** * Create an instance of a Date object, when retrieving the updated_at attribute. * Set its locale. * * @param $value * @return Date */ protected function getUpdatedAtAttribute($value) { $date = $this['updated_at'] = Date::parse($value); $date->setLocale(LaravelLocalization::getCurrentLocale()); $locale = LaravelLocalization::getCurrentLocale(); if ($locale == 'de') { return $date->format('j. F, Y'); } else { return $date->format('jS F, Y'); } }
protected function asDateTime($value) { if (is_numeric($value)) { return Date::createFromTimestamp($value); } elseif (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $value)) { return Date::createFromFormat('Y-m-d', $value)->startOfDay(); } elseif (!$value instanceof DateTime) { $format = $this->getDateFormat(); return Date::createFromFormat($format, $value); } return Date::instance($value); }
public function testUnix() { $dates = [ '1446552000', ]; $needle = '3 ноября 2015'; foreach ($dates as $date) { $this->assertEquals($needle, Date::createFromTimestamp($date)->format('j F Y')); } }
public function getSnippets() { $posts = Post::orderBy('created_at', 'desc')->take(self::NUMBER_OF_SNIPPETS)->get(); foreach ($posts as $post) { $post->body = self::shorten_string($post->body, 40); Date::setLocale('de'); $dt = new Date("" . $post->created_at . ""); $dt = $dt->format('j F Y'); $post->loc_date = $dt; $post->url = implode("-", explode(" ", $post->title)); } return view('blog/index', ['posts' => $posts]); }
/** * Bootstrap the application events. * * @return void */ public function boot() { // Laravel 5 resource registration if (method_exists($this, 'loadTranslationsFrom')) { $this->loadTranslationsFrom($this->app->basePath() . '/vendor/jenssegers/date/src/lang', 'date'); } else { if (method_exists($this, 'package')) { $this->package('jenssegers/date'); } } // Use the Laravel translator. Date::setTranslator($this->app['translator']); }
public function getIndex() { $absens = \DB::table('t_kesiangan')->get(); $kelas = \DB::table('t_siswa_tingkat')->distinct('kd_rombel')->orderBy('kd_rombel')->get(['kd_rombel']); $headers = ['NIS', 'Nama', 'Kelas', 'Tahun Ajaran', 'Semester', 'Hari', 'Tanggal', 'Jam Datang', 'Menit Kesiangan', 'Piket', 'Keterangan']; $date = Date::now(); $th1 = strval($date->year - 1) . "/" . strval($date->year); $th2 = strval($date->year) . "/" . strval($date->year + 1); $t1 = \DB::table('t_tahun_ajaran')->where('tahun_ajaran', $th1)->get(); $t2 = \DB::table('t_tahun_ajaran')->where('tahun_ajaran', $th2)->get(); $tahun_ajaran = (object) array_merge((array) $t1, (array) $t2); return view('laporan.index', compact('headers', 'absens', 'tahun_ajaran', 'kelas')); }
public function renderHtml() { $media = $this->_currentUser->getFeed(); $data = []; foreach ($media as $photo) { /** @var \Instagram\Media $photo */ $data[] = ['image' => $photo->getLowResImage()->url, 'user' => $photo->getUser()->getUserName(), 'location' => $photo->getLocation() ? $photo->getLocation()->getName() : '', 'date' => Date::createFromTimestamp($photo->getCreatedTime())->ago(), 'caption' => $photo->getCaption() ? StrHelper::removeEmoji($photo->getCaption()->getText()) : '']; } if ($this->limit) { $data = array_chunk($data, $this->limit)[0]; } $template = $this->style ? 'instagram_' . $this->style : 'instagram'; return Application::getInstance()->jadeEngine()->render(__DIR__ . '/../../frontend/src/jade/resource/' . $template . '.jade', ['data' => $data]); }
/** * Returns the rendered Blade templates. * * @return \Illuminate\View\View */ public function showIndex() { $today = Date::now(); $startDate = Date::now(); segment_page('Status Page'); // Check if we have another starting date if (Binput::has('start_date')) { try { // If date provided is valid $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date')); segment_track('Status Page', ['start_date' => $oldDate->format('Y-m-d')]); // If trying to get a future date fallback to today if ($today->gt($oldDate)) { $startDate = $oldDate; } } catch (Exception $e) { // Fallback to today } } $metrics = null; if ($displayMetrics = Setting::get('display_graphs')) { $metrics = Metric::where('display_chart', 1)->get(); } $daysToShow = Setting::get('app_incident_days') ?: 7; $incidentDays = range(0, $daysToShow - 1); $dateTimeZone = Setting::get('app_timezone'); $incidentVisiblity = Auth::check() ? 0 : 1; $allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use($dateTimeZone) { return (new Date($incident->created_at))->setTimezone($dateTimeZone)->toDateString(); }); // Add in days that have no incidents foreach ($incidentDays as $i) { $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i); if (!isset($allIncidents[$date->toDateString()])) { $allIncidents[$date->toDateString()] = []; } } // Sort the array so it takes into account the added days $allIncidents = $allIncidents->sortBy(function ($value, $key) { return strtotime($key); }, SORT_REGULAR, true)->all(); // Scheduled maintenance code. $scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get(); // Component & Component Group lists. $usedComponentGroups = Component::where('group_id', '>', 0)->groupBy('group_id')->lists('group_id'); $componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get(); $ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get(); $canPageBackward = Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() != 0; return View::make('index', ['componentGroups' => $componentGroups, 'ungroupedComponents' => $ungroupedComponents, 'displayMetrics' => $displayMetrics, 'metrics' => $metrics, 'allIncidents' => $allIncidents, 'scheduledMaintenance' => $scheduledMaintenance, 'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')), 'canPageForward' => (bool) $today->gt($startDate), 'canPageBackward' => $canPageBackward, 'previousDate' => $startDate->copy()->subDays($daysToShow)->toDateString(), 'nextDate' => $startDate->copy()->addDays($daysToShow)->toDateString(), 'pageTitle' => Setting::get('app_name') . ' Status']); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { $supportedLanguages = $request->getLanguages(); $userLanguage = $this->config->get('app.locale'); foreach ($supportedLanguages as $language) { $language = str_replace('_', '-', $language); if (isset($this->langs[$language])) { $userLanguage = $language; break; } } app('translator')->setLocale($userLanguage); Date::setLocale($userLanguage); return $next($request); }
/** * Return a timestamp as DateTime object. * * @param mixed $value * @return \Jenssegers\Date\Date */ protected function asDateTime($value) { // If this value is an integer, we will assume it is a UNIX timestamp's value // and format a Carbon object from this timestamp. This allows flexibility // when defining your date fields as they might be UNIX timestamps here. if (is_numeric($value)) { return Date::createFromTimestamp($value); } elseif (preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})$/', $value)) { return Date::createFromFormat('Y-m-d', $value)->startOfDay(); } elseif (!$value instanceof DateTime) { $format = $this->getDateFormat(); return Date::createFromFormat($format, $value); } return Date::instance($value); }