Added date format setting

Fixes #379
Closes #380

Signed-off-by: Graham Campbell <graham@mineuk.com>
This commit is contained in:
Martin Bastien 2015-01-14 20:30:23 +00:00 committed by Graham Campbell
parent e568968a70
commit de288f2084
5 changed files with 18 additions and 5 deletions

View File

@ -59,6 +59,7 @@ return [
'site-url' => 'URL der Seite',
'site-timezone' => 'Wählen Sie Ihre Zeitzone',
'site-locale' => 'Wählen Sie Ihre Sprache',
'date-format' => 'Datumsformat',
'about-this-page' => 'Über diese Seite',
'days-of-incidents' => 'Wie viele (vergangene) Tage sollen angezeigt werden?',
'banner' => 'Banner-Bild',

View File

@ -60,6 +60,7 @@ return [
'site-url' => 'Site URL',
'site-timezone' => 'Site Timezone',
'site-locale' => 'Site Language',
'date-format' => 'Date Format',
'about-this-page' => 'About this page',
'days-of-incidents' => 'How many days of incidents to show?',
'banner' => 'Banner Image',

View File

@ -59,6 +59,7 @@ return [
'site-url' => 'URL du site',
'site-timezone' => 'Fuseau horaire du site',
'site-locale' => 'Langue du site',
'date-format' => 'Format de date',
'about-this-page' => 'À propos de cette page',
'days-of-incidents' => 'Nombre de jours à afficher ?',
'banner' => 'Bannière',

View File

@ -63,6 +63,14 @@
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label>{{ trans('forms.settings.app-setup.date-format') }}</label>
<input type="text" class="form-control" name="date_format" value="{{ Setting::get('date_format') ?: 'jS F Y' }}" />
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group">

View File

@ -5,12 +5,12 @@ namespace CachetHQ\Cachet\Http\Controllers;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\Setting;
use Carbon\Carbon;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\View;
use Jenssegers\Date\Date;
class HomeController extends Controller
{
@ -27,14 +27,16 @@ class HomeController extends Controller
$incidentDays = Setting::get('app_incident_days') ?: 7;
$today = Carbon::now();
$startDate = Carbon::now();
$today = Date::now();
$startDate = Date::now();
$dateFormat = Setting::get('date_format') ?: 'jS F Y';
// Check if we have another starting date
if (Binput::has('start_date')) {
try {
// If date provided is valid
$oldDate = Carbon::createFromFormat('Y-m-d', Binput::get('start_date'));
$oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
// If trying to get a future date fallback to today
if ($today->gt($oldDate)) {
$startDate = $oldDate;
@ -50,7 +52,7 @@ class HomeController extends Controller
$date->format('Y-m-d').' 00:00:00',
$date->format('Y-m-d').' 23:59:59',
])->orderBy('created_at', 'desc')->get();
$allIncidents[] = ['date' => $date->format('jS F Y'), 'incidents' => $incidents];
$allIncidents[] = ['date' => $date->format($dateFormat), 'incidents' => $incidents];
}
return View::make('index', [