TaskFreak hacking: changing first day of week to Monday

I have two personal TaskFreak installations now: one at work and a personal one for everything else.

Usually I run all my applications in English but the personal TaskFreak is in Swedish so the first thing I changed was a couple of things I didn’t agree with in the Swedish translation.

Then there was the issue with the calendar having Sunday as the first day of the week. For me, and probably 99.99% of all Swedes, it’s like wearing your trousers the wrong way round. Our weeks start on Mondays.

Assuming all users of the TaskFreak installation agree on this, it is very easy to fix:

  1. Open taskfreak/jscalendar/calendar-setup.php in your favorite text editor
  2. Find the line
    param_default("firstDay",0);
  3. Change 0 to 1
  4. Reload your TaskFreak web page

I hope to write a separate blog post about my coolest TaskFreak hack: a script that receives e-mails and creates a corresponding task in TaskFreak.

11 comments

  1. Hi !!

    I use Taskfreak and i see that you well know this application…

    Can you say me how to replace deadlinDate in frk_item which is typed date by a typed field datetime ?

    Thanks a lot

  2. Hi

    Yes i would like for deadlineDate in frk_item…this type : datetime so this format : %d/%m/%y %H:%M:%S … because i m french 🙂

    When i create a task i want for the deadline field : 25/02/09 15:10:00 for example

    In fact i could do it but when i record my task in the mysql database, i always have 2009-02-25 00:00:00

    Hours, Minutes ans Secondes are always at 0 !!!

    Thanks a lot

  3. yes i did it but nothing change !!

    The code is complicated …maybe when the application make a record in the database, it trunk the value or reformat it … but i don’t find where

  4. Unfortunately I don’t have time to experiment right now, but I notice that you probably also should change:

    deadlineDate’ => ‘DTE’,

    in pkg_project.php to:

    deadlineDate’ => ‘DTM’,

  5. yes it’s better but not enought…

    In fact you can see bottom all what i changed and the probleme is when i create a task i see the deadlineDate whith good format (xx/xx/xxxx xx:xx:xx) but when i record my task in the tab at index.php i’ve got “- ” and in the database i’v got “0000-00-00 00:00:00”

    Strange no ?

    include/config.php
    ———————–

    before :
    // === DATE FORMATS ===========================================
    define(“TZN_DATE_SHT”,”%d %b %y”);
    define(“TZN_DATE_SHX”,”%a %d %b %y”);
    define(“TZN_DATE_LNG”,”%d %B %Y”);
    define(“TZN_DATE_LNX”,”%A %d %B %Y”);
    define(“TZN_DATETIME_EUR”,”%d/%m/%y %H:%M”);
    define(“TZN_DATETIME_USA”,”%m/%d/%y %I:%M%p”);
    define(“TZN_DATETIME_SHT”,”%d %b %y %H:%M”);
    define(“TZN_DATETIME_SHX”,”%a %d %b %y %H:%M”);
    define(“TZN_DATETIME_LNG”,”%d %B %Y, %H:%M”);
    define(“TZN_DATETIME_LNX”,”%A %d %B %Y, %H:%M”);

    after :
    // === DATE FORMATS ===========================================
    define(“TZN_DATE_SHT”,”%d %b %y”);
    define(“TZN_DATE_SHX”,”%a %d %b %y”);
    define(“TZN_DATE_LNG”,”%d %B %Y”);
    define(“TZN_DATE_LNX”,”%A %d %B %Y”);
    define(“TZN_DATETIME_EUR”,”%d/%m/%y %H:%M:%S”);
    define(“TZN_DATETIME_USA”,”%m/%d/%y %I:%M%p:%S”);
    define(“TZN_DATETIME_SHT”,”%d %b %y %H:%M:%S”);
    define(“TZN_DATETIME_SHX”,”%a %d %b %y %H:%M:%S”);
    define(“TZN_DATETIME_LNG”,”%d %B %Y, %H:%M:%S”);
    define(“TZN_DATETIME_LNX”,”%A %d %B %Y, %H:%M:%S”);

    include/tzn_generic.php
    ———————–

    before :
    define(“TZN_DATE_SQL”,”%Y-%m-%d”);
    define(“TZN_DATETIME_SQL”,”%Y-%m-%d %H:%M:%s”);

    if (@constant(‘TZN_DATE_US_FORMAT’)) {
    define(“TZN_DATE_FRM”,”%m/%d/%y”); // US format
    } else {
    define(“TZN_DATE_FRM”,”%d/%m/%y”); // rest of the world dd/mm …
    }

    after :
    define(“TZN_DATE_SQL”,”%Y-%m-%d”);
    define(“TZN_DATETIME_SQL”,”%Y-%m-%d %H:%M:%S”);

    if (@constant(‘TZN_DATE_US_FORMAT’)) {
    define(“TZN_DATE_FRM”,”%m/%d/%y”); // US format
    } else {
    define(“TZN_DATE_FRM”,”%d/%m/%y %H:%M:%S”); // rest of the world dd/mm ….
    }

    jscalendar/calendar-setup.php
    —————————–

    before :
    param_default(“ifFormat”,””);
    param_default(“daFormat”,”%d %b %y”);

    after :
    param_default(“ifFormat”,””);
    param_default(“daFormat”,”%d %b %y %H %M %S”);

    jscalendar/calendar-setup.js
    —————————-

    before :
    param_default(“ifFormat”,”%d/%m/%y”);
    param_default(“daFormat”,”%d %b %y”);

    after :
    param_default(“ifFormat”,”%d/%m/%y %H:%M:%S”);
    param_default(“daFormat”,”%d %b %y %H %M %S”);

    include/classes/pkg_project.php
    ——————————-

    before :
    ‘deadlineDate’ => ‘DTE’,

    after :
    ‘deadlineDate’ => ‘DTM’,

  6. Hi

    Ok i begin to understand…

    I have to change setDte in setDtm in some of the files too with datelineDate in parameters.

    But it’s not enought again

    I have to have in the field deadlineDate with the calendar this format :2009-11-2 04:24:00 for example… and that’s good

    But when i click on a day in the calendar my field become “2/11/2009 04:24:00” and that’s not good after the record of this task

    How to have after a click the format i want for the date ?

    thanks a lot

  7. Hello

    So …

    calendar-setup.js
    ———————
    —[find]—
    param_default(“ifFormat”,”%d/%m/%y”);
    —[replace]—
    param_default(“ifFormat”,”%d-%m-%y %H:%i:%s”);
    —[find]—
    param_default(“daFormat”,”%d %b %y”);
    —[replace]—
    param_default(“daFormat”,”%d-%m-%y %H:%i:%s”);

    —[find]—
    param_default(“showsTime”,false);
    —[replace]—
    param_default(“showsTime”,true);

    calendar-setup.php
    ——————-

    —[find]—
    param_default(“ifFormat”,””);
    —[replace]—
    param_default(“ifFormat”,””);
    —[find]—
    param_default(“daFormat”,”%d %b %y”);
    —[replace]—
    param_default(“daFormat”,”%d-%m-%y %H:%i:%s”);

    —[find]—
    param_default(“showsTime”,false);
    —[replace]—
    param_default(“showsTime”,true);

    config.php
    ———–

    —[find]—
    define(“TZN_DATE_SHT”,”%d %b %y”);
    define(“TZN_DATE_SHX”,”%a %d %b %y”);
    define(“TZN_DATE_LNG”,”%d %B %Y”);
    define(“TZN_DATE_LNX”,”%A %d %B %Y”);
    define(“TZN_DATETIME_EUR”,”%d/%m/%y %H:%M”);
    define(“TZN_DATETIME_USA”,”%m/%d/%y %I:%M%p”);
    define(“TZN_DATETIME_SHT”,”%d %b %y %H:%M”);
    define(“TZN_DATETIME_SHX”,”%a %d %b %y %H:%M”);
    define(“TZN_DATETIME_LNG”,”%d %B %Y, %H:%M”);
    define(“TZN_DATETIME_LNX”,”%A %d %B %Y, %H:%M”);
    —[replace]—
    define(“TZN_DATE_SHT”,”%d-%m-%y”);
    define(“TZN_DATE_SHX”,”%d-%m-%y”);
    define(“TZN_DATE_LNG”,”%d-%m-%y”);
    define(“TZN_DATE_LNX”,”%d-%m-%y”);
    define(“TZN_DATETIME_EUR”,”%d-%m-%y %H:%M:%S”);
    define(“TZN_DATETIME_USA”,”%d-%m-%y %H:%M:%S”);
    define(“TZN_DATETIME_SHT”,”%a %d %b %Y %H:%M”);
    define(“TZN_DATETIME_SHX”,”%a %d %b %Y %H:%M:%S”);
    define(“TZN_DATETIME_LNG”,”%d-%m-%y %H:%M:%S”);
    define(“TZN_DATETIME_LNX”,”%d-%m-%y %H:%M:%S”);

    pkg_project.php
    —————-

    —[find]—
    ‘deadlineDate’ => ‘DTE’,
    —[replace]—
    ‘deadlineDate’ => ‘DTM’,

    —[find]—
    function getDeadline($short=false) {
    if (ereg(‘(9999|0000)’,$this->deadlineDate)) {
    return ‘-‘;
    } else {
    $dead = strtotime($this->deadlineDate);
    $diff = $dead – intval(PRJ_DTE_NOW) ;
    if ($diff itemStatus->statusKey < FRK_STATUS_LEVELS) {
    return ”.$this->getDte(‘deadlineDate’,$format).”;
    } else {
    return ”.$this->getDte(‘deadlineDate’,$format).”;
    }
    } else if ($diff == 0) {
    if (@constant(‘FRK_DATEDIFF_MODE’) == ‘date’) {
    return ”.$this->getDte(‘deadlineDate’,($short)?’SHT’:’SHX’,”).”;
    } else {
    return ”.$GLOBALS[‘langTznDate’][‘today’].”;
    }
    } else if ($short) {
    $diff = $diff / 3600 / 24;
    switch (@constant(‘FRK_DATEDIFF_MODE’)) {
    case ‘day’:
    if (@constant(‘FRK_DATEDIFF_TOMORROW’) && $diff == 1) {
    return $GLOBALS[‘langTznDate’][‘tomorrow’];
    } else if ($diff < 7) {
    $day = strtolower(date(‘l’,$dead));
    if (array_key_exists($day,$GLOBALS[‘langTznDate’])) {
    $day = ucfirst($GLOBALS[‘langTznDate’][$day]);
    }
    return ”.ucFirst($day).”;
    } else {
    return ”
    .$this->getDte(‘deadlineDate’,($short)?’SHT’:’SHX’,”)
    .”;
    }
    break;
    case ‘diff’:
    switch($diff) {
    case ‘1’:
    if (@constant(‘FRK_DATEDIFF_TOMORROW’)) {
    return $GLOBALS[‘langTznDate’][‘tomorrow’];
    } else {
    return ‘1 ‘.$GLOBALS[‘langTznDate’][‘day’];
    }
    break;
    case ‘2’:
    case ‘3’:
    case ‘4’:
    case ‘5’:
    case ‘6’:
    return $diff.’ ‘.$GLOBALS[‘langTznDate’][‘dasy’];
    break;
    default:
    return ”
    .$this->getDte(‘deadlineDate’,($short)?’SHT’:’SHX’,”)
    .”;
    break;
    }
    break;
    default:
    return ”
    .$this->getDte(‘deadlineDate’,’SHT’,”)
    .”;
    break;
    }
    } else {
    return ”.$this->getDte(‘deadlineDate’,’SHX’).”;
    }
    }
    }
    —[replace]—
    function getDeadline($short=false) {
    if (ereg(‘(9999|0000)’,$this->deadlineDate)) {
    return ‘-‘;
    } else {
    $dead = strtotime($this->deadlineDate);
    $diff = $dead – intval(PRJ_DTE_NOW) ;
    if ($diff itemStatus->statusKey < FRK_STATUS_LEVELS) {
    return ”.$this->getDtm(‘deadlineDate’,$format).”;
    } else {
    return ”.$this->getDtm(‘deadlineDate’,$format).”;
    }
    } else if ($diff == 0) {
    if (@constant(‘FRK_DATEDIFF_MODE’) == ‘date’) {
    return ”.$this->getDtm(‘deadlineDate’,($short)?’SHT’:’SHX’,”).”;
    } else {
    return ”.$GLOBALS[‘langTznDate’][‘today’].”;
    }
    } else if ($short) {
    $diff = $diff / 3600 / 24;
    switch (@constant(‘FRK_DATEDIFF_MODE’)) {
    case ‘day’:
    if (@constant(‘FRK_DATEDIFF_TOMORROW’) && $diff == 1) {
    return $GLOBALS[‘langTznDate’][‘tomorrow’];
    } else if ($diff < 7) {
    $day = strtolower(date(‘l’,$dead));
    if (array_key_exists($day,$GLOBALS[‘langTznDate’])) {
    $day = ucfirst($GLOBALS[‘langTznDate’][$day]);
    }
    return ”.ucFirst($day).”;
    } else {
    return ”
    .$this->getDtm(‘deadlineDate’,($short)?’SHT’:’SHX’,”)
    .”;
    }
    break;
    case ‘diff’:
    switch($diff) {
    case ‘1’:
    if (@constant(‘FRK_DATEDIFF_TOMORROW’)) {
    return $GLOBALS[‘langTznDate’][‘tomorrow’];
    } else {
    return ‘1 ‘.$GLOBALS[‘langTznDate’][‘day’];
    }
    break;
    case ‘2’:
    case ‘3’:
    case ‘4’:
    case ‘5’:
    case ‘6’:
    return $diff.’ ‘.$GLOBALS[‘langTznDate’][‘dasy’];
    break;
    default:
    return ”
    .$this->getDtm(‘deadlineDate’,($short)?’SHT’:’SHX’,”)
    .”;
    break;
    }
    break;
    default:
    return ”
    .$this->getDtm(‘deadlineDate’,’SHT’,”)
    .”;
    break;
    }
    } else {
    return ”.$this->getDtm(‘deadlineDate’,’SHX’).”;
    }
    }
    }

    tzn_generic.php
    —————–

    —[find]—
    if (@constant(‘TZN_DATE_US_FORMAT’)) {
    define(“TZN_DATE_FRM”,”%m/%d/%y”); // US format
    } else {
    define(“TZN_DATE_FRM”,”%d/%m/%y”); // rest of the world dd/mm
    }
    —[replace]—
    if (@constant(‘TZN_DATE_US_FORMAT’)) {
    define(“TZN_DATE_FRM”,”%Y-%m-%d”); // US format
    } else {
    define(“TZN_DATE_FRM”,”%Y-%m-%d %H:%M:%S”); // rest of the world dd/mm
    }

    alinux

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.