+ add setting to show exact due date (instead of relative) in tasklist (GH-19)

This commit is contained in:
maxpozdeev 2023-09-11 09:48:39 +03:00
parent 1a75eec5dc
commit 288db261a9
5 changed files with 49 additions and 9 deletions

View file

@ -658,15 +658,44 @@ class TasksController extends ApiController {
$days = $oDiff->days;
if ($oDiff->invert) $days *= -1;
if ($days < -7 && !$thisYear) { $a['class'] = 'past'; $a['str'] = formatDate3(Config::get('dateformat2'), $y, $m, $d, $lang); }
elseif ($days < -7) { $a['class'] = 'past'; $a['str'] = formatDate3(Config::get('dateformatshort'), $y, $m, $d, $lang); }
elseif ($days < -1) { $a['class'] = 'past'; $a['str'] = sprintf($lang->get('daysago'), abs($days)); }
elseif ($days == -1) { $a['class'] = 'past'; $a['str'] = $lang->get('yesterday'); }
elseif ($days == 0) { $a['class'] = 'today'; $a['str'] = $lang->get('today'); }
elseif ($days == 1) { $a['class'] = 'today'; $a['str'] = $lang->get('tomorrow'); }
elseif ($days <= 7) { $a['class'] = 'soon'; $a['str'] = sprintf($lang->get('indays'), $days); }
elseif ($thisYear) { $a['class'] = 'future'; $a['str'] = formatDate3(Config::get('dateformatshort'), $y, $m, $d, $lang); }
else { $a['class'] = 'future'; $a['str'] = formatDate3(Config::get('dateformat2'), $y, $m, $d, $lang); }
$exact = Config::get('exactduedate') ? true : false;
if ($days < -7 && !$thisYear) {
$a['class'] = 'past';
$a['str'] = formatDate3(Config::get('dateformat2'), $y, $m, $d, $lang);
}
elseif ($days < -7) {
$a['class'] = 'past';
$a['str'] = formatDate3(Config::get('dateformatshort'), $y, $m, $d, $lang);
}
elseif ($days < -1) {
$a['class'] = 'past';
$a['str'] = !$exact ? sprintf($lang->get('daysago'), abs($days)) : formatDate3(Config::get('dateformatshort'), $y, $m, $d, $lang);
}
elseif ($days == -1) {
$a['class'] = 'past';
$a['str'] = !$exact ? $lang->get('yesterday') : formatDate3(Config::get('dateformatshort'), $y, $m, $d, $lang);
}
elseif ($days == 0) {
$a['class'] = 'today';
$a['str'] = !$exact ? $lang->get('today') : formatDate3(Config::get('dateformatshort'), $y, $m, $d, $lang);
}
elseif ($days == 1) {
$a['class'] = 'today';
$a['str'] = !$exact ? $lang->get('tomorrow') : formatDate3(Config::get('dateformatshort'), $y, $m, $d, $lang);
}
elseif ($days <= 7) {
$a['class'] = 'soon';
$a['str'] = !$exact ? sprintf($lang->get('indays'), $days) : formatDate3(Config::get('dateformatshort'), $y, $m, $d, $lang);
}
elseif ($thisYear) {
$a['class'] = 'future';
$a['str'] = formatDate3(Config::get('dateformatshort'), $y, $m, $d, $lang);
}
else {
$a['class'] = 'future';
$a['str'] = formatDate3(Config::get('dateformat2'), $y, $m, $d, $lang);
}
#avoid short year
$fmt = str_replace('y', 'Y', Config::get('dateformat2'));

View file

@ -81,6 +81,7 @@ class Config
# Show task date in list
'showdate' => array('default'=>0, 'type'=>'i'),
'showtime' => array('default'=>0, 'type'=>'i'),
'exactduedate' => array('default'=>0, 'type'=>'i'),
# Use Markdown syntax for notes. Set to 'v1' to use old v1.6 syntax.
'markup' => array('default'=>'markdown', 'type'=>'s'),

View file

@ -183,6 +183,7 @@
"set_cancel": "Cancel",
"set_showdate": "Show task date in list",
"set_showtime": "Show time",
"set_exactduedate": "Always show due date as a date",
"set_appearance": "Appearance",
"set_appearance_system": "Same as system",
"set_appearance_light": "Light",

View file

@ -183,6 +183,7 @@
"set_cancel": "Отмена",
"set_showdate": "Показывать дату создания задачи",
"set_showtime": "Показывать время",
"set_exactduedate": "Показывать срок исполнения всегда датой",
"set_appearance": "Тема оформления",
"set_appearance_system": "Как в системе",
"set_appearance_light": "Светлая",

View file

@ -52,6 +52,7 @@ if(isset($_POST['save']))
Config::set('title', removeNewLines(trim(_post('title'))) );
Config::set('showdate', (int)_post('showdate'));
Config::set('showtime', (int)_post('showtime'));
Config::set('exactduedate', (int)_post('exactduedate'));
Config::set('appearance', removeNewLines(trim(_post('appearance'))) );
Config::save();
$t['saved'] = 1;
@ -365,6 +366,13 @@ header('Content-type:text/html; charset=utf-8');
</div>
</div>
<div class="tr">
<div class="th"><?php _e('set_exactduedate');?>:</div>
<div class="td">
<label><input type="radio" name="exactduedate" value="1" <?php if(_c('exactduedate')) echo 'checked="checked"'; ?> /> <?php _e('set_enabled');?></label> <br/>
<label><input type="radio" name="exactduedate" value="0" <?php if(!_c('exactduedate')) echo 'checked="checked"'; ?> /> <?php _e('set_disabled');?></label>
</div></div>
<div class="tr">
<div class="th"><?php _e('set_appearance');?>:</div>
<div class="td">