mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
* Date formats fixed (improved?)
This commit is contained in:
parent
c875160890
commit
667384fab3
8 changed files with 52 additions and 30 deletions
23
src/ajax.php
23
src/ajax.php
|
|
@ -524,9 +524,9 @@ function prepareTaskRow($r)
|
|||
{
|
||||
$lang = Lang::instance();
|
||||
$dueA = prepare_duedate($r['duedate']);
|
||||
$formatCreatedInline = $formatCompletedInline = 'M d';
|
||||
if(date('Y') != date('Y',$r['d_created'])) $formatCreatedInline = 'M Y';
|
||||
if($r['d_completed'] && date('Y') != date('Y',$r['d_completed'])) $formatCompletedInline = 'M Y';
|
||||
$formatCreatedInline = $formatCompletedInline = Config::get('dateformatshort');
|
||||
if(date('Y') != date('Y',$r['d_created'])) $formatCreatedInline = Config::get('dateformat2');
|
||||
if($r['d_completed'] && date('Y') != date('Y',$r['d_completed'])) $formatCompletedInline = Config::get('dateformat2');
|
||||
|
||||
$dCreated = timestampToDatetime($r['d_created']);
|
||||
$dCompleted = $r['d_completed'] ? timestampToDatetime($r['d_completed']) : '';
|
||||
|
|
@ -681,13 +681,17 @@ function tag_size($qmin, $q, $step)
|
|||
|
||||
function parse_duedate($s)
|
||||
{
|
||||
$df2 = Config::get('dateformat2');
|
||||
if(max((int)strpos($df2,'n'), (int)strpos($df2,'m')) > max((int)strpos($df2,'d'), (int)strpos($df2,'j'))) $formatDayFirst = true;
|
||||
else $formatDayFirst = false;
|
||||
|
||||
$y = $m = $d = 0;
|
||||
if(preg_match("|^(\d+)-(\d+)-(\d+)\b|", $s, $ma)) {
|
||||
$y = (int)$ma[1]; $m = (int)$ma[2]; $d = (int)$ma[3];
|
||||
}
|
||||
elseif(preg_match("|^(\d+)\/(\d+)\/(\d+)\b|", $s, $ma))
|
||||
{
|
||||
if(Config::get('duedateformat') == 4) {
|
||||
if($formatDayFirst) {
|
||||
$d = (int)$ma[1]; $m = (int)$ma[2]; $y = (int)$ma[3];
|
||||
} else {
|
||||
$m = (int)$ma[1]; $d = (int)$ma[2]; $y = (int)$ma[3];
|
||||
|
|
@ -704,7 +708,7 @@ function parse_duedate($s)
|
|||
}
|
||||
elseif(preg_match("|^(\d+)\/(\d+)\b|", $s, $ma))
|
||||
{
|
||||
if(Config::get('duedateformat') == 4) {
|
||||
if($formatDayFirst) {
|
||||
$d = (int)$ma[1]; $m = (int)$ma[2];
|
||||
} else {
|
||||
$m = (int)$ma[1]; $d = (int)$ma[2];
|
||||
|
|
@ -738,19 +742,16 @@ function prepare_duedate($duedate)
|
|||
$diff = mktime(0,0,0,$ad[1],$ad[2],$ad[0]) - mktime(0,0,0,$at[1],$at[2],$at[0]);
|
||||
|
||||
if($diff < -604800 && $ad[0] == $at[0]) { $a['class'] = 'past'; $a['str'] = formatDate3(Config::get('dateformatshort'), (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang); }
|
||||
elseif($diff < -604800) { $a['class'] = 'past'; $a['str'] = formatDate3(Config::get('dateformat'), (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang); }
|
||||
elseif($diff < -604800) { $a['class'] = 'past'; $a['str'] = formatDate3(Config::get('dateformat2'), (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang); }
|
||||
elseif($diff < -86400) { $a['class'] = 'past'; $a['str'] = sprintf($lang->get('daysago'),ceil(abs($diff)/86400)); }
|
||||
elseif($diff < 0) { $a['class'] = 'past'; $a['str'] = $lang->get('yesterday'); }
|
||||
elseif($diff < 86400) { $a['class'] = 'today'; $a['str'] = $lang->get('today'); }
|
||||
elseif($diff < 172800) { $a['class'] = 'today'; $a['str'] = $lang->get('tomorrow'); }
|
||||
elseif($diff < 691200) { $a['class'] = 'soon'; $a['str'] = sprintf($lang->get('indays'),ceil($diff/86400)); }
|
||||
elseif($ad[0] == $at[0]) { $a['class'] = 'future'; $a['str'] = formatDate3(Config::get('dateformatshort'), (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang); }
|
||||
else { $a['class'] = 'future'; $a['str'] = formatDate3(Config::get('dateformat'), (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang); }
|
||||
else { $a['class'] = 'future'; $a['str'] = formatDate3(Config::get('dateformat2'), (int)$ad[0], (int)$ad[1], (int)$ad[2], $lang); }
|
||||
|
||||
if(Config::get('duedateformat') == 2) $a['formatted'] = (int)$ad[1].'/'.(int)$ad[2].'/'.$ad[0];
|
||||
elseif(Config::get('duedateformat') == 3) $a['formatted'] = $ad[2].'.'.$ad[1].'.'.$ad[0];
|
||||
elseif(Config::get('duedateformat') == 4) $a['formatted'] = $ad[2].'/'.$ad[1].'/'.$ad[0];
|
||||
else $a['formatted'] = $duedate;
|
||||
$a['formatted'] = formatTime(Config::get('dateformat2'), $a['timestamp']);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ class Config
|
|||
'session' => array('default'=>'files', 'type'=>'s', 'options'=>array('files','default')),
|
||||
'clock' => array('default'=>24, 'type'=>'i', 'options'=>array(12,24)),
|
||||
'dateformat' => array('default'=>'j M Y', 'type'=>'s'),
|
||||
'dateformat2' => array('default'=>'n/j/y', 'type'=>'s'),
|
||||
'dateformatshort' => array('default'=>'j M', 'type'=>'s'),
|
||||
'template' => array('default'=>'default', 'type'=>'s'),
|
||||
'showdate' => array('default'=>0, 'type'=>'i'),
|
||||
|
|
@ -134,13 +135,14 @@ function formatDate3($format, $ay, $am, $ad, $lang)
|
|||
$ml = $lang->get('months_long');
|
||||
$ms = $lang->get('months_short');
|
||||
$Y = $ay;
|
||||
$y = $Y < 2010 ? '0'.($Y-2000) : $Y-2000;
|
||||
$n = $am;
|
||||
$m = $n < 10 ? '0'.$n : $n;
|
||||
$F = $ml[$am-1];
|
||||
$M = $ms[$am-1];
|
||||
$j = $ad;
|
||||
$d = $j < 10 ? '0'.$j : $j;
|
||||
return strtr($format, array('Y'=>$Y, 'F'=>$F, 'M'=>$M, 'n'=>$n, 'm'=>$m, 'd'=>$d, 'j'=>$j));
|
||||
return strtr($format, array('Y'=>$Y, 'y'=>$y, 'F'=>$F, 'M'=>$M, 'n'=>$n, 'm'=>$m, 'd'=>$d, 'j'=>$j));
|
||||
}
|
||||
|
||||
function url_dir($url)
|
||||
|
|
|
|||
|
|
@ -118,8 +118,8 @@ class DefaultLang
|
|||
'set_sessions_php' => "PHP",
|
||||
'set_sessions_files' => "Files",
|
||||
'set_firstdayofweek' => "First day of week",
|
||||
'set_duedate' => "Duedate calendar format",
|
||||
'set_date' => "Date format",
|
||||
'set_date2' => "Date format (short)",
|
||||
'set_shortdate' => "Short Date format",
|
||||
'set_clock' => "Clock format",
|
||||
'set_12hour' => "12-hour",
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ class Lang extends DefaultLang
|
|||
'set_sessions_php' => "PHP",
|
||||
'set_sessions_files' => "Files",
|
||||
'set_firstdayofweek' => "First day of week",
|
||||
'set_duedate' => "Duedate calendar format",
|
||||
'set_date' => "Date format",
|
||||
'set_date2' => "Date format (short)",
|
||||
'set_shortdate' => "Short Date format",
|
||||
'set_clock' => "Clock format",
|
||||
'set_12hour' => "12-hour",
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ var mytinytodo = window.mytinytodo = _mtt = {
|
|||
this.applySingletab();
|
||||
|
||||
$("#duedate").datepicker({
|
||||
dateFormat: _mtt.datepickerformat(),
|
||||
dateFormat: _mtt.duedatepickerformat(),
|
||||
firstDay: _mtt.options.firstdayofweek,
|
||||
showOn: 'button',
|
||||
buttonImage: _mtt.templateUrl + 'images/calendar.png', buttonImageOnly: true,
|
||||
|
|
@ -536,13 +536,26 @@ var mytinytodo = window.mytinytodo = _mtt = {
|
|||
if(onInit) updateAccessStatus();
|
||||
},
|
||||
|
||||
datepickerformat: function()
|
||||
duedatepickerformat: function()
|
||||
{
|
||||
var fmt = 'yy-mm-dd';
|
||||
if(this.options.duedateformat == 2) fmt = 'm/d/yy';
|
||||
else if(this.options.duedateformat == 3) fmt = 'dd.mm.yy';
|
||||
else if(this.options.duedateformat == 4) fmt = 'dd/mm/yy';
|
||||
return fmt;
|
||||
if(!this.options.duedatepickerformat) return 'yy-mm-dd';
|
||||
|
||||
var s = this.options.duedatepickerformat.replace(/(.)/g, function(t,s) {
|
||||
switch(t) {
|
||||
case 'Y': return 'yy';
|
||||
case 'y': return 'y';
|
||||
case 'd': return 'dd';
|
||||
case 'j': return 'd';
|
||||
case 'm': return 'mm';
|
||||
case 'n': return 'm';
|
||||
case '.':
|
||||
case '-': return t;
|
||||
default: return '';
|
||||
}
|
||||
});
|
||||
|
||||
if(s == '') return 'yy-mm-dd';
|
||||
return s;
|
||||
},
|
||||
|
||||
errorDenied: function()
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ if(isset($_POST['save']))
|
|||
Config::set('autotag', (int)_post('autotag'));
|
||||
Config::set('session', _post('session'));
|
||||
Config::set('firstdayofweek', (int)_post('firstdayofweek'));
|
||||
Config::set('duedateformat', (int)_post('duedateformat'));
|
||||
Config::set('clock', (int)_post('clock'));
|
||||
Config::set('dateformat', _post('dateformat'));
|
||||
Config::set('dateformat2', _post('dateformat2'));
|
||||
Config::set('dateformatshort', _post('dateformatshort'));
|
||||
Config::set('title', trim(_post('title')));
|
||||
Config::set('showdate', (int)_post('showdate'));
|
||||
|
|
@ -196,12 +196,6 @@ function timezoneIdentifiers()
|
|||
<select name="firstdayofweek"><?php echo selectOptions(__('days_long'), _c('firstdayofweek')); ?></select>
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<th><?php _e('set_duedate');?>:</th>
|
||||
<td>
|
||||
<select name="duedateformat"><?php echo selectOptions(array(1=>'yyyy-mm-dd ('.date('Y-m-d').')', 2=>'m/d/yyyy ('.date('n/j/Y').')', 3=>'dd.mm.yyyy ('.date('d.m.Y').')', 4=>'dd/mm/yyyy ('.date('d/m/Y').')'), _c('duedateformat')); ?></select>
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<th><?php _e('set_date');?>:</th>
|
||||
<td>
|
||||
|
|
@ -212,6 +206,18 @@ function timezoneIdentifiers()
|
|||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<th><?php _e('set_date2');?>:</th>
|
||||
<td>
|
||||
<input name="dateformat2" value="<?php echo htmlspecialchars(_c('dateformat2'));?>" />
|
||||
<select onchange="if(this.value!=0) this.form.dateformat2.value=this.value;">
|
||||
<?php echo selectOptions(array('Y-m-d'=>'yyyy-mm-dd ('.date('Y-m-d').')',
|
||||
'n/j/y'=>'m/d/yy ('.date('n/j/y').')',
|
||||
'd.m.y'=>'dd.mm.yy ('.date('d.m.y').')',
|
||||
'd/m/y'=>'dd/mm/yy ('.date('d/m/y').')', 0=>'Custom'), _c('dateformat2')); ?>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<th><?php _e('set_shortdate');?>:</th>
|
||||
<td>
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ $().ready(function(){
|
|||
isLogged: <?php echo ($needAuth && is_logged()) ? "true" : "false"; ?>,
|
||||
showdate: <?php echo (Config::get('showdate') && !isset($_GET['pda'])) ? "true" : "false"; ?>,
|
||||
singletab: <?php echo (isset($_GET['singletab']) || isset($_GET['pda'])) ? "true" : "false"; ?>,
|
||||
duedateformat: <?php echo (int)Config::get('duedateformat'); ?>,
|
||||
duedatepickerformat: "<?php echo htmlspecialchars(Config::get('dateformat2')); ?>",
|
||||
autotag: <?php echo Config::get('autotag') ? "true" : "false"; ?>
|
||||
<?php if(isset($_GET['list'])) echo ",openList: ". (int)$_GET['list']; ?>
|
||||
}).loadLists(1);
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ li.task-expanded .task-toggle { background-position:-80px -16px; }
|
|||
#tasklist li { padding:6px 2px 6px 6px; border-bottom:1px solid #DEDEDE; min-height:18px; margin-bottom:1px; background-color:#fff; }
|
||||
#tasklist li:hover { background-color:#f6f6f6; }
|
||||
.task-actions { float:right; width:25px; text-align:right; }
|
||||
.task-date { display:none; min-width:55px; color:#999999; margin-right:10px; margin-left:5px; }
|
||||
.task-date { display:none; min-width:55px; color:#999999; margin-right:10px; margin-left:5px; text-align:right; }
|
||||
.task-date-completed { color:#999999; display:none; margin-left:5px; }
|
||||
.show-inline-date .task-middle { margin-left:110px; }
|
||||
.show-inline-date .task-date { display:inline-block; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue