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'), 'title' => t('Application settings'),
'languages' => $this->config->getLanguages(), 'languages' => $this->config->getLanguages(),
'timezones' => $this->config->getTimezones(), 'timezones' => $this->config->getTimezones(),
'date_formats' => $this->dateParser->getAvailableFormats(),
))); )));
} }

View File

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

View File

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

View File

@@ -209,8 +209,6 @@ return array(
'The description is required' => 'Eine Beschreibung wird benötigt', 'The description is required' => 'Eine Beschreibung wird benötigt',
'Edit this task' => 'Aufgabe bearbeiten', 'Edit this task' => 'Aufgabe bearbeiten',
'Due Date' => 'Fällig am', 'Due Date' => 'Fällig am',
'm/d/Y' => 'd.m.Y',
'month/day/year' => 'TT.MM.JJJJ',
'Invalid date' => 'Ungültiges Datum', 'Invalid date' => 'Ungültiges Datum',
'Must be done before %B %e, %Y' => 'Muss vor dem %d.%m.%Y erledigt werden', 'Must be done before %B %e, %Y' => 'Muss vor dem %d.%m.%Y erledigt werden',
'%B %e, %Y' => '%d.%m.%Y', '%B %e, %Y' => '%d.%m.%Y',
@@ -534,4 +532,6 @@ return array(
// 'Application URL' => '', // 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '', // 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '', // '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', 'The description is required' => 'La descripción es obligatoria',
'Edit this task' => 'Editar esta tarea', 'Edit this task' => 'Editar esta tarea',
'Due Date' => 'Fecha límite', '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', 'Invalid date' => 'Fecha no válida',
'Must be done before %B %e, %Y' => 'Debe de estar hecho antes del %d/%m/%Y', 'Must be done before %B %e, %Y' => 'Debe de estar hecho antes del %d/%m/%Y',
'%B %e, %Y' => '%d/%m/%Y', '%B %e, %Y' => '%d/%m/%Y',
@@ -534,4 +532,6 @@ return array(
// 'Application URL' => '', // 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '', // 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '', // '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', 'The description is required' => 'Kuvaus vaaditaan',
'Edit this task' => 'Muokkaa tehtävää', 'Edit this task' => 'Muokkaa tehtävää',
'Due Date' => 'Deadline', 'Due Date' => 'Deadline',
'm/d/Y' => 'd.m.Y',
'month/day/year' => 'päivä.kuukausi.vuosi',
'Invalid date' => 'Virheellinen päiväys', 'Invalid date' => 'Virheellinen päiväys',
'Must be done before %B %e, %Y' => 'Täytyy suorittaa ennen %d.%m.%Y', 'Must be done before %B %e, %Y' => 'Täytyy suorittaa ennen %d.%m.%Y',
'%B %e, %Y' => '%d.%m.%Y', '%B %e, %Y' => '%d.%m.%Y',
@@ -534,4 +532,6 @@ return array(
// 'Application URL' => '', // 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '', // 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '', // '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', 'The description is required' => 'La description est obligatoire',
'Edit this task' => 'Modifier cette tâche', 'Edit this task' => 'Modifier cette tâche',
'Due Date' => 'Date d\'échéance', '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', 'Invalid date' => 'Date invalide',
'Must be done before %B %e, %Y' => 'Doit être fait avant le %d/%m/%Y', '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', 'Automatic actions' => 'Actions automatisées',
'Your automatic action have been created successfully.' => 'Votre action automatisée a été ajouté avec succès.', '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.', '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', 'Application URL' => 'URL de l\'application',
'Example: http://example.kanboard.net/ (used by email notifications)' => 'Exemple : http://exemple.kanboard.net/ (utilisé pour les notifications)', '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é.', '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', 'The description is required' => 'Si richiede una descrizione',
'Edit this task' => 'Modificare questo compito', 'Edit this task' => 'Modificare questo compito',
'Due Date' => 'Data di scadenza', 'Due Date' => 'Data di scadenza',
'm/d/Y' => 'd/m/Y',
'month/day/year' => 'giorno/mese/anno',
'Invalid date' => 'Data sbagliata', 'Invalid date' => 'Data sbagliata',
// 'Must be done before %B %e, %Y' => '', // 'Must be done before %B %e, %Y' => '',
// '%B %e, %Y' => '', // '%B %e, %Y' => '',
@@ -534,4 +532,6 @@ return array(
// 'Application URL' => '', // 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '', // 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '', // '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', 'The description is required' => 'Opis jest wymagany',
'Edit this task' => 'Edytuj zadanie', 'Edit this task' => 'Edytuj zadanie',
'Due Date' => 'Termin', 'Due Date' => 'Termin',
'm/d/Y' => 'd/m/Y',
'month/day/year' => 'dzień/miesiąc/rok',
'Invalid date' => 'Błędna data', 'Invalid date' => 'Błędna data',
'Must be done before %B %e, %Y' => 'Termin do %e %B %Y', 'Must be done before %B %e, %Y' => 'Termin do %e %B %Y',
'%B %e, %Y' => '%e %B %Y', '%B %e, %Y' => '%e %B %Y',
@@ -534,4 +532,6 @@ return array(
// 'Application URL' => '', // 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '', // 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '', // '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', 'The description is required' => 'A descrição é obrigatória',
'Edit this task' => 'Editar esta tarefa', 'Edit this task' => 'Editar esta tarefa',
'Due Date' => 'Data de vencimento', 'Due Date' => 'Data de vencimento',
'm/d/Y' => 'd/m/Y',
'month/day/year' => 'dia/mês/ano',
'Invalid date' => 'Data inválida', 'Invalid date' => 'Data inválida',
'Must be done before %B %e, %Y' => 'Deve ser feito antes de %d %B %Y', 'Must be done before %B %e, %Y' => 'Deve ser feito antes de %d %B %Y',
'%B %e, %Y' => '%d %B %Y', '%B %e, %Y' => '%d %B %Y',
@@ -534,4 +532,6 @@ return array(
// 'Application URL' => '', // 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '', // 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '', // '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' => 'Требуется описание', 'The description is required' => 'Требуется описание',
'Edit this task' => 'Изменить задачу', 'Edit this task' => 'Изменить задачу',
'Due Date' => 'Срок', 'Due Date' => 'Срок',
'm/d/Y' => 'м/д/Г',
'month/day/year' => 'месяц/день/год',
'Invalid date' => 'Неверная дата', 'Invalid date' => 'Неверная дата',
'Must be done before %B %e, %Y' => 'Должно быть сделано до %d/%m/%Y', 'Must be done before %B %e, %Y' => 'Должно быть сделано до %d/%m/%Y',
'%B %e, %Y' => '%d/%m/%Y', '%B %e, %Y' => '%d/%m/%Y',
@@ -534,4 +532,6 @@ return array(
// 'Application URL' => '', // 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '', // 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '', // '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', 'The description is required' => 'En beskrivning måste lämnas',
'Edit this task' => 'Ändra denna uppgift', 'Edit this task' => 'Ändra denna uppgift',
'Due Date' => 'Måldatum', 'Due Date' => 'Måldatum',
'm/d/Y' => 'd/m/Y',
'month/day/year' => 'dag/månad/år',
'Invalid date' => 'Ej tillåtet datum', 'Invalid date' => 'Ej tillåtet datum',
'Must be done before %B %e, %Y' => 'Måste vara klart innan %B %e, %Y', 'Must be done before %B %e, %Y' => 'Måste vara klart innan %B %e, %Y',
'%B %e, %Y' => '%d %B %Y', '%B %e, %Y' => '%d %B %Y',
@@ -534,4 +532,6 @@ return array(
// 'Application URL' => '', // 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '', // 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '', // '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' => '必须得有描述', 'The description is required' => '必须得有描述',
'Edit this task' => '编辑该任务', 'Edit this task' => '编辑该任务',
'Due Date' => '到期', 'Due Date' => '到期',
'm/d/Y' => 'Y/m/d',
'month/day/year' => '年/月/日',
'Invalid date' => '无效日期', 'Invalid date' => '无效日期',
'Must be done before %B %e, %Y' => '必须在%Y年%m月%d日前完成', 'Must be done before %B %e, %Y' => '必须在%Y年%m月%d日前完成',
'%B %e, %Y' => '%Y/%m/%d', '%B %e, %Y' => '%Y/%m/%d',
@@ -534,4 +532,6 @@ return array(
// 'Application URL' => '', // 'Application URL' => '',
// 'Example: http://example.kanboard.net/ (used by email notifications)' => '', // 'Example: http://example.kanboard.net/ (used by email notifications)' => '',
// 'Token regenerated.' => '', // '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 * @access public
* @return array * @return array
@@ -65,12 +65,27 @@ class DateParser extends Base
public function getDateFormats() public function getDateFormats()
{ {
return array( return array(
t('m/d/Y'), $this->config->get('application_date_format', 'm/d/Y'),
'Y-m-d', 'Y-m-d',
'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 * For a given timestamp, reset the date to midnight
* *

View File

@@ -5,7 +5,13 @@ namespace Schema;
use PDO; use PDO;
use Core\Security; 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) function version_29($pdo)
{ {

View File

@@ -5,7 +5,13 @@ namespace Schema;
use PDO; use PDO;
use Core\Security; 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) function version_10($pdo)
{ {

View File

@@ -5,7 +5,13 @@ namespace Schema;
use Core\Security; use Core\Security;
use PDO; 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) function version_29($pdo)
{ {

View File

@@ -16,6 +16,10 @@
<?= Helper\form_label(t('Timezone'), 'application_timezone') ?> <?= Helper\form_label(t('Timezone'), 'application_timezone') ?>
<?= Helper\form_select('application_timezone', $timezones, $values, $errors) ?><br/> <?= 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"> <div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/> <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
</div> </div>

View File

@@ -11,10 +11,10 @@
<?= Helper\form_hidden('project_id', $values) ?> <?= Helper\form_hidden('project_id', $values) ?>
<?= Helper\form_label(t('Start Date'), 'from') ?> <?= 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_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> <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_number('score', $values, $errors) ?><br/>
<?= Helper\form_label(t('Due Date'), 'date_due') ?> <?= 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 class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>
</div> </div>

View File

@@ -39,7 +39,7 @@
<?= Helper\form_number('score', $values, $errors) ?><br/> <?= Helper\form_number('score', $values, $errors) ?><br/>
<?= Helper\form_label(t('Due Date'), 'date_due') ?> <?= 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 class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>
</div> </div>

View File

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

View File

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