DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:todo:customisations

ToDo Plugin

Customizations

Customize the date format

The todo plugin doesn't use the Date format set by strftime so if you want to use a date format other than yyyy/mm/dd you'll have to make some modifications.

Note that these modification will not survive updates.

Rather than doing this customization, just add a pull request to the github repo, either add date format as a config option or update code to use dokuwikis dformat config option — Christian Marg 2020-02-06 16:20

Example:- Change to the Australian date format (dd/mm/yyyy)

  1. Edit action.php and change
    $newTag = preg_replace('/>/', ' #'.$user.':'.date('Y-m-d').'>', $todoTag)

    to

    $newTag = preg_replace('/>/', ' #'.$user.':'.date('d-m-Y').'>', $todoTag)
  2. Edit syntax/todo.php and change
    if(date('Y-m-d', strtotime($completeddate)) == $completeddate) {

    to

    if(date('d-m-Y', strtotime($completeddate)) == $completeddate) {

    , change

    case 'start':
    if(date('Y-m-d', strtotime($value)) == $value) {

    to

    case 'start':
    if(date('d-m-Y', strtotime($value)) == $value) {

    , and change

    case 'due':
                            if(date('Y-m-d', strtotime($value)) == $value) {

    to

    case 'due':
                            if(date('Y-m-d', strtotime($value)) == $value) {

    and change

    if(isset($data['start'])) { $return .= $data['start']->format('Y-m-d'); }
                $return .= ' → ';
                if(isset($data['due'])) { $return .= $data['due']->format('d-m-Y'); }

    to

    if(isset($data['start'])) { $return .= $data['start']->format('d-m-Y'); }
                $return .= ' → ';
                if(isset($data['due'])) { $return .= $data['due']->format('d-m-Y'); }
  3. Edit syntax/list.php and change
    if(date('Y-m-d', strtotime($date)) == $date) {
                        $result[0] = $date;
                    } elseif(preg_match('/^[\+\-]\d+$/', $date)) { // check if we have a valid relative va$
                        $newdate = date_create(date('Y-m-d'));
                        date_modify($newdate, $date . ' day');
                        $result[0] = date_format($newdate, 'Y-m-d');
                    } else { 
                        $result[0] = date('Y-m-d');
                    }
                }
            } else { $result[0] = date('Y-m-d'); }

    to

    if(date('d-m-Y', strtotime($date)) == $date) {
                        $result[0] = $date;
                    } elseif(preg_match('/^[\+\-]\d+$/', $date)) { // check if we have a valid relative va$
                        $newdate = date_create(date('d-m-Y'));
                        date_modify($newdate, $date . ' day');
                        $result[0] = date_format($newdate, 'd-m-Y');
                    } else { 
                        $result[0] = date('d-m-Y');
                    }
                }
            } else { $result[0] = date('d-m-Y'); }

    SFITCS 2017-03-17 12:10

plugin/todo/customisations.txt · Last modified: 2020-02-06 16:20 by einhirn

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki