Input date format is now a config parameter instead of the current locale

This commit is contained in:
Frédéric Guillot 2014-10-05 11:22:10 -04:00
parent 8e5673e3d2
commit bae57838c2
23 changed files with 84 additions and 35 deletions

View File

@ -78,6 +78,7 @@ class Config extends Base
'title' => t('Application settings'),
'languages' => $this->config->getLanguages(),
'timezones' => $this->config->getTimezones(),
'date_formats' => $this->dateParser->getAvailableFormats(),
)));
}

View File

@ -86,6 +86,8 @@ class Project extends Base
'to' => $to,
),
'errors' => array(),
'date_format' => $this->config->get('application_date_format'),
'date_formats' => $this->dateParser->getAvailableFormats(),
'menu' => 'projects',
'project' => $project,
'title' => t('Tasks Export')

View File

@ -92,6 +92,8 @@ class Task extends Base
'users_list' => $this->projectPermission->getUsersList($project_id),
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($project_id),
'date_format' => $this->config->get('application_date_format'),
'date_formats' => $this->dateParser->getAvailableFormats(),
'menu' => 'tasks',
'title' => t('New task')
)));
@ -138,6 +140,8 @@ class Task extends Base
'users_list' => $this->projectPermission->getUsersList($values['project_id']),
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($values['project_id']),
'date_format' => $this->config->get('application_date_format'),
'date_formats' => $this->dateParser->getAvailableFormats(),
'menu' => 'tasks',
'title' => t('New task')
)));
@ -153,7 +157,7 @@ class Task extends Base
$task = $this->getTask();
if (! empty($task['date_due'])) {
$task['date_due'] = date(t('m/d/Y'), $task['date_due']);
$task['date_due'] = date($this->config->get('application_date_format'), $task['date_due']);
}
else {
$task['date_due'] = '';
@ -169,6 +173,8 @@ class Task extends Base
'users_list' => $this->projectPermission->getUsersList($task['project_id']),
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($task['project_id']),
'date_format' => $this->config->get('application_date_format'),
'date_formats' => $this->dateParser->getAvailableFormats(),
'ajax' => $ajax,
'menu' => 'tasks',
'title' => t('Edit a task')
@ -219,6 +225,8 @@ class Task extends Base
'users_list' => $this->projectPermission->getUsersList($values['project_id']),
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($values['project_id']),
'date_format' => $this->config->get('application_date_format'),
'date_formats' => $this->dateParser->getAvailableFormats(),
'menu' => 'tasks',
'title' => t('Edit a task'),
'ajax' => $this->request->isAjax(),

View File

@ -209,8 +209,6 @@ return array(
'The description is required' => 'Eine Beschreibung wird benötigt',
'Edit this task' => 'Aufgabe bearbeiten',
'Due Date' => 'Fällig am',
'm/d/Y' => 'd.m.Y',
'month/day/year' => 'TT.MM.JJJJ',
'Invalid date' => 'Ungültiges Datum',
'Must be done before %B %e, %Y' => 'Muss vor dem %d.%m.%Y erledigt werden',
'%B %e, %Y' => '%d.%m.%Y',
@ -534,4 +532,6 @@ return array(
// 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '',
// 'Date format' => '',
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
);

View File

@ -209,8 +209,6 @@ return array(
'The description is required' => 'La descripción es obligatoria',
'Edit this task' => 'Editar esta tarea',
'Due Date' => 'Fecha límite',
'm/d/Y' => 'd/m/Y',
'month/day/year' => 'día/mes/año',
'Invalid date' => 'Fecha no válida',
'Must be done before %B %e, %Y' => 'Debe de estar hecho antes del %d/%m/%Y',
'%B %e, %Y' => '%d/%m/%Y',
@ -534,4 +532,6 @@ return array(
// 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '',
// 'Date format' => '',
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
);

View File

@ -209,8 +209,6 @@ return array(
'The description is required' => 'Kuvaus vaaditaan',
'Edit this task' => 'Muokkaa tehtävää',
'Due Date' => 'Deadline',
'm/d/Y' => 'd.m.Y',
'month/day/year' => 'päivä.kuukausi.vuosi',
'Invalid date' => 'Virheellinen päiväys',
'Must be done before %B %e, %Y' => 'Täytyy suorittaa ennen %d.%m.%Y',
'%B %e, %Y' => '%d.%m.%Y',
@ -534,4 +532,6 @@ return array(
// 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '',
// 'Date format' => '',
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
);

View File

@ -209,11 +209,9 @@ return array(
'The description is required' => 'La description est obligatoire',
'Edit this task' => 'Modifier cette tâche',
'Due Date' => 'Date d\'échéance',
'm/d/Y' => 'd/m/Y', // Date format parsed with php
'month/day/year' => 'jour/mois/année', // Help shown to the user
'Invalid date' => 'Date invalide',
'Must be done before %B %e, %Y' => 'Doit être fait avant le %d/%m/%Y',
'%B %e, %Y' => '%d/%m/%Y',
'%B %e, %Y' => '%d %B %Y',
'Automatic actions' => 'Actions automatisées',
'Your automatic action have been created successfully.' => 'Votre action automatisée a été ajouté avec succès.',
'Unable to create your automatic action.' => 'Impossible de créer votre action automatisée.',
@ -534,4 +532,6 @@ return array(
'Application URL' => 'URL de l\'application',
'Example: http://example.kanboard.net/ (used by email notifications)' => 'Exemple : http://exemple.kanboard.net/ (utilisé pour les notifications)',
'Token regenerated.' => 'Jeton de sécurité regénéré.',
'Date format' => 'Format de date',
'ISO format is always accepted, example: "%s" and "%s"' => 'Le format ISO est toujours accepté, exemple : « %s » et « %s »',
);

View File

@ -209,8 +209,6 @@ return array(
'The description is required' => 'Si richiede una descrizione',
'Edit this task' => 'Modificare questo compito',
'Due Date' => 'Data di scadenza',
'm/d/Y' => 'd/m/Y',
'month/day/year' => 'giorno/mese/anno',
'Invalid date' => 'Data sbagliata',
// 'Must be done before %B %e, %Y' => '',
// '%B %e, %Y' => '',
@ -534,4 +532,6 @@ return array(
// 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '',
// 'Date format' => '',
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
);

View File

@ -209,8 +209,6 @@ return array(
'The description is required' => 'Opis jest wymagany',
'Edit this task' => 'Edytuj zadanie',
'Due Date' => 'Termin',
'm/d/Y' => 'd/m/Y',
'month/day/year' => 'dzień/miesiąc/rok',
'Invalid date' => 'Błędna data',
'Must be done before %B %e, %Y' => 'Termin do %e %B %Y',
'%B %e, %Y' => '%e %B %Y',
@ -534,4 +532,6 @@ return array(
// 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '',
// 'Date format' => '',
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
);

View File

@ -209,8 +209,6 @@ return array(
'The description is required' => 'A descrição é obrigatória',
'Edit this task' => 'Editar esta tarefa',
'Due Date' => 'Data de vencimento',
'm/d/Y' => 'd/m/Y',
'month/day/year' => 'dia/mês/ano',
'Invalid date' => 'Data inválida',
'Must be done before %B %e, %Y' => 'Deve ser feito antes de %d %B %Y',
'%B %e, %Y' => '%d %B %Y',
@ -534,4 +532,6 @@ return array(
// 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '',
// 'Date format' => '',
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
);

View File

@ -209,8 +209,6 @@ return array(
'The description is required' => 'Требуется описание',
'Edit this task' => 'Изменить задачу',
'Due Date' => 'Срок',
'm/d/Y' => 'м/д/Г',
'month/day/year' => 'месяц/день/год',
'Invalid date' => 'Неверная дата',
'Must be done before %B %e, %Y' => 'Должно быть сделано до %d/%m/%Y',
'%B %e, %Y' => '%d/%m/%Y',
@ -534,4 +532,6 @@ return array(
// 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '',
// 'Date format' => '',
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
);

View File

@ -209,8 +209,6 @@ return array(
'The description is required' => 'En beskrivning måste lämnas',
'Edit this task' => 'Ändra denna uppgift',
'Due Date' => 'Måldatum',
'm/d/Y' => 'd/m/Y',
'month/day/year' => 'dag/månad/år',
'Invalid date' => 'Ej tillåtet datum',
'Must be done before %B %e, %Y' => 'Måste vara klart innan %B %e, %Y',
'%B %e, %Y' => '%d %B %Y',
@ -534,4 +532,6 @@ return array(
// 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '',
// 'Date format' => '',
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
);

View File

@ -209,8 +209,6 @@ return array(
'The description is required' => '必须得有描述',
'Edit this task' => '编辑该任务',
'Due Date' => '到期',
'm/d/Y' => 'Y/m/d',
'month/day/year' => '年/月/日',
'Invalid date' => '无效日期',
'Must be done before %B %e, %Y' => '必须在%Y年%m月%d日前完成',
'%B %e, %Y' => '%Y/%m/%d',
@ -534,4 +532,6 @@ return array(
// 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '',
// 'Date format' => '',
// 'ISO format is always accepted, example: "%s" and "%s"' => '',
);

View File

@ -57,7 +57,7 @@ class DateParser extends Base
}
/**
* Return the list of supported date formats
* Return the list of supported date formats (for the parser)
*
* @access public
* @return array
@ -65,12 +65,27 @@ class DateParser extends Base
public function getDateFormats()
{
return array(
t('m/d/Y'),
$this->config->get('application_date_format', 'm/d/Y'),
'Y-m-d',
'Y_m_d',
);
}
/**
* Return the list of available date formats (for the config page)
*
* @access public
* @return array
*/
public function getAvailableFormats()
{
return array(
'm/d/Y' => date('m/d/Y'),
'd/m/Y' => date('d/m/Y'),
'Y/m/d' => date('Y/m/d'),
);
}
/**
* For a given timestamp, reset the date to midnight
*

View File

@ -5,7 +5,13 @@ namespace Schema;
use PDO;
use Core\Security;
const VERSION = 29;
const VERSION = 30;
function version_30($pdo)
{
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
$rq->execute(array('application_date_format', 'm/d/Y'));
}
function version_29($pdo)
{

View File

@ -5,7 +5,13 @@ namespace Schema;
use PDO;
use Core\Security;
const VERSION = 10;
const VERSION = 11;
function version_11($pdo)
{
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
$rq->execute(array('application_date_format', 'm/d/Y'));
}
function version_10($pdo)
{

View File

@ -5,7 +5,13 @@ namespace Schema;
use Core\Security;
use PDO;
const VERSION = 29;
const VERSION = 30;
function version_30($pdo)
{
$rq = $pdo->prepare('INSERT INTO settings VALUES (?, ?)');
$rq->execute(array('application_date_format', 'm/d/Y'));
}
function version_29($pdo)
{

View File

@ -16,6 +16,10 @@
<?= Helper\form_label(t('Timezone'), 'application_timezone') ?>
<?= Helper\form_select('application_timezone', $timezones, $values, $errors) ?><br/>
<?= Helper\form_label(t('Date format'), 'application_date_format') ?>
<?= Helper\form_select('application_date_format', $date_formats, $values, $errors) ?><br/>
<p class="form-help"><?= t('ISO format is always accepted, example: "%s" and "%s"', date('Y-m-d'), date('Y_m_d')) ?></p>
<div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
</div>

View File

@ -11,10 +11,10 @@
<?= Helper\form_hidden('project_id', $values) ?>
<?= Helper\form_label(t('Start Date'), 'from') ?>
<?= Helper\form_text('from', $values, $errors, array('required', 'placeholder="'.t('month/day/year').'"'), 'form-date') ?><br/>
<?= Helper\form_text('from', $values, $errors, array('required', 'placeholder="'.Helper\in_list($date_format, $date_formats).'"'), 'form-date') ?><br/>
<?= Helper\form_label(t('End Date'), 'to') ?>
<?= Helper\form_text('to', $values, $errors, array('required', 'placeholder="'.t('month/day/year').'"'), 'form-date') ?>
<?= Helper\form_text('to', $values, $errors, array('required', 'placeholder="'.Helper\in_list($date_format, $date_formats).'"'), 'form-date') ?>
<div class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>

View File

@ -34,7 +34,7 @@
<?= Helper\form_number('score', $values, $errors) ?><br/>
<?= Helper\form_label(t('Due Date'), 'date_due') ?>
<?= Helper\form_text('date_due', $values, $errors, array('placeholder="'.t('month/day/year').'"'), 'form-date') ?><br/>
<?= Helper\form_text('date_due', $values, $errors, array('placeholder="'.Helper\in_list($date_format, $date_formats).'"'), 'form-date') ?><br/>
<div class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>
</div>

View File

@ -39,7 +39,7 @@
<?= Helper\form_number('score', $values, $errors) ?><br/>
<?= Helper\form_label(t('Due Date'), 'date_due') ?>
<?= Helper\form_text('date_due', $values, $errors, array('placeholder="'.t('month/day/year').'"'), 'form-date') ?><br/>
<?= Helper\form_text('date_due', $values, $errors, array('placeholder="'.Helper\in_list($date_format, $date_formats).'"'), 'form-date') ?><br/>
<div class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>
</div>

View File

@ -187,17 +187,17 @@ select {
}
::-webkit-input-placeholder {
color: #bbb;
color: #ddd;
padding-top: 2px;
}
::-ms-input-placeholder {
color: #bbb;
color: #ddd;
padding-top: 2px;
}
::-moz-placeholder {
color: #bbb;
color: #ddd;
padding-top: 2px;
}

View File

@ -64,7 +64,8 @@ var Kanboard = (function() {
$(".form-date").datepicker({
showOtherMonths: true,
selectOtherMonths: true,
dateFormat: 'yy-mm-dd'
dateFormat: 'yy-mm-dd',
constrainInput: false
});
}
};