Anonymous Login
2016-12-04 02:52 CET

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
04765User patchesSurvey designpublic2012-06-21 13:22
Reporteruser9586 
Assigned Toc_schmitz 
PrioritynormalSeverityminor 
StatusclosedResolutionfixed 
Product Version1.90 
Target VersionFixed in Version2.00 
Summary04765: New "datetime" question type
DescriptionAs discussed here: http://sourceforge.net/mailarchive/forum.php?thread_name=20100910163018.da050f0b.yuri.delia%40eurac.edu&forum_name=limesurvey-developers

I've implemented a new question type, "datetime" (type '/' internally), which works like the 'date' question type, but allows an user-specified date format. The date format can contain YmdHi specifiers, allowing to be used also a time question type or any partial date (like my original requirement of a year-month only date).

Dates can be entered both textually and with selection boxes, exactly like 'date'. The selection boxes are built automatically by parsing the date format.

There's also a new question attribute, "datetime_minutes_step", which allows to present the minutes part in controllable steps (usually in 10 or 15 minutes).

Internally the date is stored as a string, but since it's always formatted according to the date format it's easily parseable.

The default time format, if not specified, is taken from the survey's default date format.
TagsNo tags attached.
Complete LimeSurvey version number (& build)9535
Attached Files
  • patch file icon datetime.patch (43,384 bytes) 2011-02-04 16:01 -
    Index: save.php
    ===================================================================
    --- save.php	(revision 9740)
    +++ save.php	(working copy)
    @@ -174,13 +174,12 @@
                 //Iterate through possible responses
                 if (isset($_SESSION[$value]) && isset($fieldexists) && $_SESSION[$value]!='')
                 {
    -
                     if ($fieldexists['type']=='D' && isset($_POST[$value]))  // convert the date to the right DB Format
                     {
    -                    $dateformatdatat=getDateFormatData($thissurvey['surveyls_dateformat']);
    -                    $datetimeobj = new Date_Time_Converter($_SESSION[$value], $dateformatdatat['phpdate']);
    -                    $_SESSION[$value]=$datetimeobj->convert("Y-m-d");
    -                    $_SESSION[$value]=$connect->BindDate($_SESSION[$value]);
    +                    $qidattributes = getQuestionAttributes($fieldexists['qid']);
    +                    $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $thissurvey);
    +                    $datetimeobj = new Date_Time_Converter($_SESSION[$value], $dateformatdetails['phpdate']);
    +                    $_SESSION[$value] = $connect->BindTimeStamp($datetimeobj->convert('Y-m-d H:i:s'));
                     }
                 }
             }
    @@ -534,10 +533,10 @@
                         elseif ($fieldexists['type']=='D' && is_array($postedfieldnames) && in_array($value,$postedfieldnames))
                         {
                             // convert the date to the right DB Format but only if it was posted
    -                        $dateformatdatat=getDateFormatData($thissurvey['surveyls_dateformat']);
    -                        $datetimeobj = new Date_Time_Converter($_SESSION[$value], $dateformatdatat['phpdate']);
    -                        $_SESSION[$value]=$datetimeobj->convert("Y-m-d");
    -                        $_SESSION[$value]=$connect->BindDate($_SESSION[$value]);
    +                        $qidattributes = getQuestionAttributes($fieldexists['qid']);
    +                        $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $thissurvey);
    +                        $datetimeobj = new Date_Time_Converter($_SESSION[$value], $dateformatdetails['phpdate']);
    +                        $_SESSION[$value] = $connect->BindTimeStamp($datetimeobj->convert('Y-m-d H:i:s'));
                         }
                         $values[]=$connect->qstr($_SESSION[$value],get_magic_quotes_gpc());
                     }
    @@ -692,9 +691,10 @@
                                 }
                                 elseif ($fieldinfo['type']=='D')  // convert the date to the right DB Format
                                 {
    -                                $dateformatdatat=getDateFormatData($thissurvey['surveyls_dateformat']);
    -                                $datetimeobj = new Date_Time_Converter($_POST[$field], $dateformatdatat['phpdate']);
    -                                $qfield=db_quoteall($connect->BindDate($datetimeobj->convert("Y-m-d")));
    +                                $qidattributes = getQuestionAttributes($fieldinfo['qid']);
    +                                $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $thissurvey);
    +                                $datetimeobj = new Date_Time_Converter($_POST[$field], $dateformatdetails['phpdate']);
    +                                $qfield = db_quoteall($connect->BindTimeStamp($datetimeobj->convert('Y-m-d H:i:s')));
                                 }
                                 else
                                 {
    Index: scripts/jquery/lime-calendar.js
    ===================================================================
    --- scripts/jquery/lime-calendar.js	(revision 9740)
    +++ scripts/jquery/lime-calendar.js	(working copy)
    @@ -1,4 +1,5 @@
     $(document).ready(function(){
    +    // pupup calendar
     	$(".popupdate").each(function(i,e) { 
             var basename = e.id.substr(6);         
             format=$('#dateformat'+basename).val();
    @@ -16,10 +17,13 @@
                               duration: 'fast'
                             }, $.datepicker.regional[language]);
         });
    +
    +    // dropdown dates
         $('.month').change(dateUpdater);
         $('.day').change(dateUpdater)
         $('.year').change(dateUpdater);
    -    $('.year').change();
    +    $('.hour').change(dateUpdater);
    +    $('.minute').change(dateUpdater);
     });
     
     
    @@ -29,66 +33,62 @@
         {
             thisid=this.id.substr(4);
         }
    -    if(this.id.substr(0,3)=='mon')
    +    else if(this.id.substr(0,3)=='mon')
         {
             thisid=this.id.substr(5);
         }
    -    if(this.id.substr(0,3)=='day')
    +    else if(this.id.substr(0,3)=='day')
         {
             thisid=this.id.substr(3);
         }
    +    else if(this.id.substr(0,3)=='hou')
    +    {
    +        thisid=this.id.substr(4);
    +    }
    +    else if(this.id.substr(0,3)=='min')
    +    {
    +        thisid=this.id.substr(6);
    +    }
     
    -    
    -    if (($('#year'+thisid).val()=='') && ($('#month'+thisid).val()=='') && ($('#day'+thisid).val()=='')){
    +    if ((!$('#year'+thisid).length || $('#year'+thisid).val()=='') &&
    +            (!$('#month'+thisid).length || $('#month'+thisid).val()=='') &&
    +            (!$('#day'+thisid).length || $('#day'+thisid).val()=='') &&
    +            (!$('#hour'+thisid).length || $('#hour'+thisid).val()=='') &&
    +            (!$('#minute'+thisid).length || $('#minute'+thisid).val()==''))
    +    {
             $('#qattribute_answer'+thisid).val('');
             $('#answer'+thisid).val('');
    +        $('#answer'+thisid).change();
         }
    -    else if (($('#year'+thisid).val()=='') || ($('#month'+thisid).val()=='') || ($('#day'+thisid).val()=='')){
    +    else if (($('#year'+thisid).length && $('#year'+thisid).val()=='') ||
    +            ($('#month'+thisid).length && $('#month'+thisid).val()=='') ||
    +            ($('#day'+thisid).length && $('#day'+thisid).val()=='') ||
    +            ($('#hour'+thisid).length && $('#hour'+thisid).val()==''))
    +    {
             $('#qattribute_answer'+thisid).val('Please complete all parts of the date!');
             $('#answer'+thisid).val('');
         }
         else
         {
    -         ValidDate(this,$('#year'+thisid).val()+'-'+$('#month'+thisid).val()+'-'+$('#day'+thisid).val());          
    -         parseddate=$.datepicker.parseDate( 'dd-mm-yy', $('#day'+thisid).val()+'-'+$('#month'+thisid).val()+'-'+$('#year'+thisid).val());
    -         $('#answer'+thisid).val($.datepicker.formatDate( $('#dateformat'+thisid).val(), parseddate)); 
    -         $('#answer'+thisid).change();
    -         $('#qattribute_answer'+thisid).val('');
    +        var answer = $('#dateformat'+thisid).val();
    +        if ($('#year'+thisid).length) answer = answer.replace(/y+/, $('#year'+thisid).val());
    +        if ($('#month'+thisid).length) answer = answer.replace(/m+/, $('#month'+thisid).val());
    +        if ($('#day'+thisid).length) answer = answer.replace(/d+/, $('#day'+thisid).val());
    +        if ($('#hour'+thisid).length) answer = answer.replace(/H+/, $('#hour'+thisid).val());
    +        if ($('#minute'+thisid).length)
    +        {
    +            // The minute is optional (assumed as 00)
    +            if ($('#minute'+thisid).val()=='')
    +            {
    +                answer = answer.replace(/M+/, '00');
    +            }
    +            else
    +            {
    +                answer = answer.replace(/M+/, $('#minute'+thisid).val());
    +            }
    +        }
    +        $('#answer'+thisid).val(answer);
    +        $('#answer'+thisid).change();
    +        $('#qattribute_answer'+thisid).val('');
         }
     }
    -
    -
    -function ValidDate(oObject, value) {// Regular expression used to check if date is in correct format 
    -    var str_regexp = /[1-9][0-9]{3}-(0[1-9]|1[0-2])-([0-2][0-9]|3[0-1])/; 
    -    var pattern = new RegExp(str_regexp); 
    -    if ((value.match(pattern)!=null)) 
    -    {
    -        var date_array = value.split('-'); 
    -        var day = date_array[2]; 
    -        var month = date_array[1]; 
    -        var year = date_array[0]; 
    -        str_regexp = /1|3|5|7|8|10|12/; 
    -        pattern = new RegExp(str_regexp); 
    -        if ( day <= 31 && (month.match(pattern)!=null)) 
    -        { 
    -            return true; 
    -        } 
    -        str_regexp = /4|6|9|11/; 
    -        pattern = new RegExp(str_regexp); 
    -        if ( day <= 30 && (month.match(pattern)!=null)) 
    -        { 
    -            return true; 
    -        } 
    -        if (day == 29 && month == 2 && (year % 4 == 0)) 
    -        { 
    -            return true; 
    -        } 
    -        if (day <= 28 && month == 2) 
    -        { 
    -            return true; 
    -        }         
    -    } 
    -    window.alert('Date is not valid!'); 
    -    oObject.focus(); 
    -    return false; 
    -} 
    \ No newline at end of file
    Index: common_functions.php
    ===================================================================
    --- common_functions.php	(revision 9740)
    +++ common_functions.php	(working copy)
    @@ -127,7 +127,7 @@
                    'hasdefaultvalues'=>0,
                    'assessable'=>1,
                    'answerscales'=>0),
    -    "D"=>array('description'=>$clang->gT("Date"),
    +    "D"=>array('description'=>$clang->gT("Date/Time"),
                    'group'=>$group['MaskQuestions'],
                    'subquestions'=>0,
                    'hasdefaultvalues'=>0,
    @@ -1792,7 +1792,7 @@
      * @param mixed $dateformatid
      * @return string
      */
    -function getextendedanswer($fieldcode, $value, $format='', $dateformatphp='d.m.Y')
    +function getextendedanswer($fieldcode, $value, $format='')
     {
     
         global $dbprefix, $surveyid, $connect, $clang, $action;
    @@ -1819,8 +1819,9 @@
             {
                 case 'D': if (trim($value)!='')
                 {
    -                $datetimeobj = new Date_Time_Converter($value , "Y-m-d H:i:s");
    -                $value=$datetimeobj->convert($dateformatphp);
    +                $qidattributes = getQuestionAttributes($fields['qid']);
    +                $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $surveyid);
    +                $value = DateTime::createFromFormat("Y-m-d H:i:s", $value)->format($dateformatdetails['phpdate']);
                 }
                 break;
                 case "L":
    @@ -3333,7 +3334,7 @@
         {
             $answreplace=substr($line, strpos($line, "{INSERTANS:"), strpos($line, "}", strpos($line, "{INSERTANS:"))-strpos($line, "{INSERTANS:")+1);
             $answreplace2=substr($answreplace, 11, strpos($answreplace, "}", strpos($answreplace, "{INSERTANS:"))-11);
    -        $answreplace3=strip_tags(retrieve_Answer($answreplace2, $_SESSION['dateformats']['phpdate']));
    +        $answreplace3=strip_tags(retrieve_Answer($answreplace2));
             $line=str_replace($answreplace, $answreplace3, $line);
         }
         return $line;
    @@ -4488,6 +4489,34 @@
     	"help"=>$clang->gT("CSS style used when the 2nd 'time limit warning' message is displayed"),
     	"caption"=>$clang->gT("2nd time limit warning CSS style"));
     
    +    $qattributes["date_format"]=array(
    +	"types"=>"D",
    +    'category'=>$clang->gT('Input'),
    +    'sortorder'=>100,
    +    "inputtype"=>"text",
    +	"help"=>$clang->gT("Specify a custom date/time format (the <i>d/dd m/mm yy/yyyy H/HH M/MM</i> formats and \"-./: \" characters are allowed for day/month/year/hour/minutes without or with leading zero respectively. Defaults to survey's date format"),
    +	"caption"=>$clang->gT("Date/Time format"));
    +
    +    $qattributes["dropdown_dates_minute_step"]=array(
    +	"types"=>"D",
    +    'category'=>$clang->gT('Input'),
    +    'sortorder'=>100,
    +    "inputtype"=>"integer",
    +	"help"=>$clang->gT("Minute step interval when using select boxes"),
    +	"caption"=>$clang->gT("Minute step interval"));
    +
    +    $qattributes["dropdown_dates_month_style"]=array(
    +	"types"=>"D",
    +    'category'=>$clang->gT('Display'),
    +    'sortorder'=>100,
    +    "inputtype"=>"singleselect",
    +    'options'=>array(0=>$clang->gT('Short names'),
    +    1=>$clang->gT('Full names'),
    +    2=>$clang->gT('Numbers')),
    +    'default'=>0,
    +	"help"=>$clang->gT("Change the display style of the month when using select boxes"),
    +	"caption"=>$clang->gT("Month display style"));
    +
         $qattributes["show_title"]=array(
     	"types"=>"|",
         'category'=>$clang->gT('File metadata'),
    @@ -6478,7 +6507,7 @@
      * @param mixed $phpdateformat  The date format in which any dates are shown
      * @return mixed returns the answerText from session variable corresponding to a question code
      */
    -function retrieve_Answer($code, $phpdateformat=null)
    +function retrieve_Answer($code)
     {
         //This function checks to see if there is an answer saved in the survey session
         //data that matches the $code. If it does, it returns that data.
    @@ -6536,7 +6565,7 @@
             }
             else
             {
    -            $return=getextendedanswer($code, $_SESSION[$code], 'INSERTANS',$phpdateformat);
    +            $return=getextendedanswer($code, $_SESSION[$code], 'INSERTANS');
             }
         }
         else
    Index: qanda.php
    ===================================================================
    --- qanda.php	(revision 9740)
    +++ qanda.php	(working copy)
    @@ -1713,20 +1713,35 @@
             $checkconditionFunction = "noop_checkconditions";
         }
     
    -    $dateformatdetails=getDateFormatData($thissurvey['surveyls_dateformat']);
    -    $numberformatdatat = getRadixPointData($thissurvey['surveyls_numberformat']);
    +    $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $thissurvey);
     
         if (trim($qidattributes['dropdown_dates'])!=0) {
             if (!empty($_SESSION[$ia[1]]))
             {
    -            list($currentyear, $currentmonth, $currentdate) = explode('-', $_SESSION[$ia[1]]);
    +            $datetimeobj = getdate(DateTime::createFromFormat("Y-m-d H:i:s", $_SESSION[$ia[1]])->getTimeStamp());
    +            $currentyear = $datetimeobj['year'];
    +            $currentmonth = $datetimeobj['mon'];
    +            $currentdate = $datetimeobj['mday'];
    +            $currenthour = $datetimeobj['hours'];
    +            $currentminute = $datetimeobj['minutes'];
             } else {
                 $currentdate='';
                 $currentmonth='';
                 $currentyear='';
    +            $currenthour='';
    +            $currentminute='';
             }
     
    -        $dateorder = preg_split('/[-\.\/ ]/', $dateformatdetails['phpdate']);
    +        if (trim($qidattributes['dropdown_dates_minute_step'])!=0)
    +        {
    +            $iMinuteStep = trim($qidattributes['dropdown_dates_minute_step']);
    +        }
    +        else
    +        {
    +            $iMinuteStep = 1;
    +        }
    +
    +        $dateorder = preg_split('/[-\.\/: ]/', $dateformatdetails['phpdate']);
             $answer='<p class="question">';
             foreach($dateorder as $datepart)
             {
    @@ -1745,7 +1760,8 @@
                         {
                             $i_date_selected = '';
                         }
    -                    $answer .= '    <option value="'.sprintf('%02d', $i).'"'.$i_date_selected.'>'.sprintf('%02d', $i)."</option>\n";
    +                    $format = ($datepart == 'j'? "%d": "%02d");
    +                    $answer .= '    <option value="'.sprintf($format, $i).'"'.$i_date_selected.'>'.sprintf($format, $i)."</option>\n";
                     }
                     $answer .='</select>';
                     break;
    @@ -1753,19 +1769,49 @@
                     case 'n':
                     case 'm':   $answer .= ' <select id="month'.$ia[1].'" class="month">
                                                 <option value="">'.$clang->gT('Month')."</option>\n";
    -                $montharray=array(
    -                $clang->gT('Jan'),
    -                $clang->gT('Feb'),
    -                $clang->gT('Mar'),
    -                $clang->gT('Apr'),
    -                $clang->gT('May'),
    -                $clang->gT('Jun'),
    -                $clang->gT('Jul'),
    -                $clang->gT('Aug'),
    -                $clang->gT('Sep'),
    -                $clang->gT('Oct'),
    -                $clang->gT('Nov'),
    -                $clang->gT('Dec'));
    +                $format = ($datepart == 'n'? "%d": "%02d");
    +                switch(trim($qidattributes['dropdown_dates_month_style']))
    +                {
    +                    case 1: // full month names
    +                    $montharray=array(
    +                    $clang->gT('January'),
    +                    $clang->gT('February'),
    +                    $clang->gT('March'),
    +                    $clang->gT('April'),
    +                    $clang->gT('May'),
    +                    $clang->gT('June'),
    +                    $clang->gT('July'),
    +                    $clang->gT('August'),
    +                    $clang->gT('September'),
    +                    $clang->gT('October'),
    +                    $clang->gT('November'),
    +                    $clang->gT('December'));
    +                    break;
    +
    +                    case 2: // numbers
    +                    $montharray=array();
    +                    for ($i=1; $i<=12; $i++)
    +                    {
    +                        $montharray[] = sprintf($format, $i);
    +                    }
    +                    break;
    +
    +                    default: // short names
    +                    $montharray=array(
    +                    $clang->gT('Jan'),
    +                    $clang->gT('Feb'),
    +                    $clang->gT('Mar'),
    +                    $clang->gT('Apr'),
    +                    $clang->gT('May'),
    +                    $clang->gT('Jun'),
    +                    $clang->gT('Jul'),
    +                    $clang->gT('Aug'),
    +                    $clang->gT('Sep'),
    +                    $clang->gT('Oct'),
    +                    $clang->gT('Nov'),
    +                    $clang->gT('Dec'));
    +                    break;
    +                }
                     for ($i=1; $i<=12; $i++) {
                         if ($i == $currentmonth)
                         {
    @@ -1776,11 +1822,12 @@
                             $i_date_selected = '';
                         }
     
    -                    $answer .= '    <option value="'.sprintf('%02d', $i).'"'.$i_date_selected.'>'.$montharray[$i-1].'</option>';
    +                    $answer .= '    <option value="'.sprintf($format, $i).'"'.$i_date_selected.'>'.$montharray[$i-1].'</option>';
                     }
                     $answer .= '    </select>';
                     break;
                     // Show year select box
    +                case 'y':
                     case 'Y':   $answer .= ' <select id="year'.$ia[1].'" class="year">
                                                 <option value="">'.$clang->gT('Year').'</option>';
     
    @@ -1797,7 +1844,7 @@
                     }
                     else
                     {
    -                    $yearmin = 1900;
    +                    $yearmin = 1970;
                     }
     
                     if (trim($qidattributes['dropdown_dates_year_max'])!='')
    @@ -1811,7 +1858,7 @@
     
                     if ($yearmin > $yearmax)
                     {
    -                    $yearmin = 1900;
    +                    $yearmin = 1970;
                         $yearmax = 2020;
                     }
     
    @@ -1829,6 +1876,11 @@
                         $reverse = false;
                     }
     
    +                if ($datepart == 'y' && $yearmin < 2000)
    +                {
    +                    $yearmin = 2000;
    +                }
    +
                     for ($i=$yearmax; ($reverse? $i<=$yearmin: $i>=$yearmin); $i+=$step) {
                         if ($i == $currentyear)
                         {
    @@ -1838,11 +1890,46 @@
                         {
                             $i_date_selected = '';
                         }
    -                    $answer .= '  <option value="'.$i.'"'.$i_date_selected.'>'.$i.'</option>';
    +                    $y = ($datepart == 'y'? substr($i, -2): $i);
    +                    $answer .= '  <option value="'.$y.'"'.$i_date_selected.'>'.$y.'</option>';
                     }
                     $answer .= '</select>';
     
                     break;
    +                // Show hour select box
    +                case 'H':
    +                case 'G':   $answer .= ' <select id="hour'.$ia[1].'" class="hour">
    +                                                <option value="">'.$clang->gT('Hour')."</option>\n";
    +                for ($i=0; $i<=23; $i++) {
    +                    if ($i == $currenthour && is_int($currenthour))
    +                    {
    +                        $i_date_selected = SELECTED;
    +                    }
    +                    else
    +                    {
    +                        $i_date_selected = '';
    +                    }
    +                    $format = ($datepart == 'G'? "%d": "%02d");
    +                    $answer .= '    <option value="'.sprintf($format, $i).'"'.$i_date_selected.'>'.sprintf($format, $i)."</option>\n";
    +                }
    +                $answer .='</select>';
    +                break;
    +                // Show minute select box
    +                case 'i':   $answer .= ' <select id="minute'.$ia[1].'" class="minute">
    +                                                <option value="">'.$clang->gT('Minute')."</option>\n";
    +                for ($i=0; $i<=59; $i+=$iMinuteStep) {
    +                    if ($i == $currentminute && is_int($currentminute))
    +                    {
    +                        $i_date_selected = SELECTED;
    +                    }
    +                    else
    +                    {
    +                        $i_date_selected = '';
    +                    }
    +                    $answer .= '    <option value="'.sprintf('%02d', $i).'"'.$i_date_selected.'>'.sprintf('%02d', $i)."</option>\n";
    +                }
    +                $answer .='</select>';
    +                break;
                 }
             }
     
    @@ -1850,23 +1937,20 @@
     			</p>';
             $answer .= '<input type="hidden" name="qattribute_answer[]" value="'.$ia[1].'" />
     			        <input type="hidden" id="qattribute_answer'.$ia[1].'" name="qattribute_answer'.$ia[1].'" />
    -                    <input type="hidden" id="dateformat'.$ia[1].'" value="'.$dateformatdetails['jsdate'].'"/>';
    -
    -
    +                    <input type="hidden" id="dateformat'.$ia[1].'" value="'.$dateformatdetails['dateformat'].'"/>';
         }
         else
         {
             if ($clang->langcode !== 'en')
             {
    -        $js_header_includes[] = '/scripts/jquery/locale/ui.datepicker-'.$clang->langcode.'.js';
    +            $js_header_includes[] = '/scripts/jquery/locale/ui.datepicker-'.$clang->langcode.'.js';
             }
             $css_header_includes[]= '/scripts/jquery/css/start/jquery-ui.css';
     
             // Format the date  for output
             if (trim($_SESSION[$ia[1]])!='')
             {
    -            $datetimeobj = new Date_Time_Converter($_SESSION[$ia[1]] , "Y-m-d");
    -            $dateoutput=$datetimeobj->convert($dateformatdetails['phpdate']);
    +            $dateoutput = DateTime::createFromFormat("Y-m-d H:i:s", $_SESSION[$ia[1]])->format($dateformatdetails['phpdate']);
             }
             else
             {
    @@ -1889,19 +1973,29 @@
                 $maxyear='2020';
             }
     
    -        $goodchars = str_replace( array("m","d","y"), "", $dateformatdetails['jsdate']);
    +        $goodchars = str_replace( array("m","d","y", "H", "M"), "", $dateformatdetails['dateformat']);
             $goodchars = "0123456789".$goodchars[0];
     
    -        $answer ="<p class=\"question\">
    -                        <input class='popupdate' type=\"text\" alt=\"".$clang->gT('Date picker')."\" size=\"10\" name=\"{$ia[1]}\" id=\"answer{$ia[1]}\" value=\"$dateoutput\" maxlength=\"10\" onkeypress=\"return goodchars(event,'".$goodchars."')\" onchange=\"$checkconditionFunction(this.value, this.name, this.type)\" />
    -                        <input  type='hidden' name='dateformat{$ia[1]}' id='dateformat{$ia[1]}' value='{$dateformatdetails['jsdate']}'  />
    -                        <input  type='hidden' name='datelanguage{$ia[1]}' id='datelanguage{$ia[1]}' value='{$clang->langcode}'  />
    -                        <input  type='hidden' name='dateyearrange{$ia[1]}' id='dateyearrange{$ia[1]}' value='{$minyear}:{$maxyear}'  />
    -                        
    -			         </p>
    -			         <p class=\"tip\">                      
    -				         ".sprintf($clang->gT('Format: %s'),$dateformatdetails['dateformat'])."
    -			         </p>";
    +        // check if we can show the date picker
    +        if(bCanShowDatePicker($dateformatdetails))
    +        {
    +            $answer ="<p class=\"question\">
    +                          <input class='popupdate' type=\"text\" alt=\"".$clang->gT('Date picker')."\" size=\"16\" name=\"{$ia[1]}\" id=\"answer{$ia[1]}\" value=\"$dateoutput\" maxlength=\"16\" onkeypress=\"return goodchars(event,'".$goodchars."')\" onchange=\"$checkconditionFunction(this.value, this.name, this.type)\" />
    +                          <input  type='hidden' name='dateformat{$ia[1]}' id='dateformat{$ia[1]}' value='{$dateformatdetails['jsdate']}'  />
    +                          <input  type='hidden' name='datelanguage{$ia[1]}' id='datelanguage{$ia[1]}' value='{$clang->langcode}'  />
    +                          <input  type='hidden' name='dateyearrange{$ia[1]}' id='dateyearrange{$ia[1]}' value='{$minyear}:{$maxyear}'  />
    +                      </p>";
    +        }
    +        else
    +        {
    +            $answer ="<p class=\"question\">
    +                          <input type=\"text\" alt=\"".$clang->gT('Date picker')."\" size=\"16\" name=\"{$ia[1]}\" id=\"answer{$ia[1]}\" value=\"$dateoutput\" maxlength=\"16\" onkeypress=\"return goodchars(event,'".$goodchars."')\" onchange=\"$checkconditionFunction(this.value, this.name, this.type)\" />
    +                      </p>";
    +        }
    +
    +        $answer .= "<p class=\"tip\">
    +                      ".sprintf($clang->gT('Format: %s'),$dateformatdetails['dateformat'])."
    +                    </p>";
         }
         $inputnames[]=$ia[1];
     
    Index: admin/dataentry.php
    ===================================================================
    --- admin/dataentry.php	(revision 9740)
    +++ admin/dataentry.php	(working copy)
    @@ -61,8 +61,6 @@
     
     include_once("login_check.php");
     
    -$dateformatdetails=getDateFormatData($_SESSION['dateformat']);
    -
     if (!isset($sDataEntryLanguage))
     {
         $sDataEntryLanguage = GetBaseLanguageFromSurveyID($surveyid);
    @@ -277,6 +275,8 @@
                         }
                         elseif ($irow['type'] == 'D')
                         {
    +                        $qidattributes = getQuestionAttributes($irow['qid'], $irow['type']);
    +                        $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $thissurvey);
                             $datetimeobj = new Date_Time_Converter($_POST[$fieldname],$dateformatdetails['phpdate']);
                             $columns[] .= db_quote_id($fieldname);
                             $values[] .= db_quoteall($datetimeobj->convert("Y-m-d H:i:s"),true);
    @@ -565,6 +565,10 @@
                     $dataentryoutput .= "</td>\n"
                     ."<td valign='top' align='left'>\n";
                     //$dataentryoutput .= "\t-={$fname[3]}=-"; //Debugging info
    +                if(isset($fname['qid']) && isset($fname['type']))
    +                {
    +                    $qidattributes = getQuestionAttributes($fname['qid'], $fname['type']);
    +                }
                     switch ($fname['type'])
                     {
                         case "completed":
    @@ -614,12 +618,26 @@
                             break;
                         case "D": //DATE
                             $thisdate='';
    +                        $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $surveyid);
                             if ($idrow[$fname['fieldname']]!='')
                             {
    -                            $datetimeobj = new Date_Time_Converter($idrow[$fname['fieldname']] , "Y-m-d H:i:s");
    -                            $thisdate=$datetimeobj->convert($dateformatdetails['phpdate']);
    +                            $thisdate = DateTime::createFromFormat("Y-m-d H:i:s", $idrow[$fname['fieldname']])->format($dateformatdetails['phpdate']);
                             }
    -                        $dataentryoutput .= "\t<input type='text' class='popupdate' size='12' name='{$fname['fieldname']}' value='{$thisdate}' />\n";
    +                        else
    +                        {
    +                            $thisdate = '';
    +                        }
    +                        if(bCanShowDatePicker($dateformatdetails))
    +                        {
    +                            $goodchars = str_replace( array("m","d","y", "H", "M"), "", $dateformatdetails['dateformat']);
    +                            $goodchars = "0123456789".$goodchars[0];
    +                            $dataentryoutput .= "\t<input type='text' class='popupdate' size='12' name='{$fname['fieldname']}' value='{$thisdate}' onkeypress=\"return goodchars(event,'".$goodchars."')\"/>\n";
    +                            $dataentryoutput .= "\t<input type='hidden' name='dateformat{$fname['fieldname']}' id='dateformat{$fname['fieldname']}' value='{$dateformatdetails['jsdate']}'  />\n";
    +                        }
    +                        else
    +                        {
    +                            $dataentryoutput .= "\t<input type='text' name='{$fname['fieldname']}' value='{$thisdate}' />\n";
    +                        }
                             break;
                         case "G": //GENDER drop-down list
                             $dataentryoutput .= "\t<select name='{$fname['fieldname']}'>\n"
    @@ -1392,6 +1410,7 @@
                 }
             }
             
    +        $thissurvey=getSurveyInfo($surveyid);
             $updateqr = "UPDATE $surveytable SET \n";
     
             foreach ($fieldmap as $irow)
    @@ -1417,6 +1436,8 @@
                     }
                     else
                     {
    +                    $qidattributes = getQuestionAttributes($irow['qid'], $irow['type']);
    +                    $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $thissurvey);
                         $datetimeobj = new Date_Time_Converter($thisvalue,$dateformatdetails['phpdate']);
                         $updateqr .= db_quote_id($fieldname)." = '{$datetimeobj->convert("Y-m-d H:i:s")}', \n";
                     }
    @@ -1442,7 +1463,6 @@
             $updateqr .= " WHERE id=$id";
     
             $updateres = $connect->Execute($updateqr) or safe_die("Update failed:<br />\n" . $connect->ErrorMsg() . "<br />$updateqr");
    -        $thissurvey=getSurveyInfo($surveyid);
             while (ob_get_level() > 0) {
                 ob_end_flush();
             }
    @@ -1794,9 +1814,19 @@
                             $dataentryoutput .= "\t</select>\n";
                             break;
                         case "D": //DATE
    -                        $datetimeobj = new Date_Time_Converter('', "Y-m-d H:i:s");
    -                        $thisdate=$datetimeobj->convert($dateformatdetails['phpdate']);
    -                        $dataentryoutput .= "\t<input type='text' class='popupdate' size='12' name='$fieldname'/>\n";
    +                        $qidattributes = getQuestionAttributes($deqrow['qid'], $deqrow['type']);
    +                        $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $thissurvey);
    +                        if(bCanShowDatePicker($dateformatdetails))
    +                        {
    +                            $goodchars = str_replace( array("m","d","y", "H", "M"), "", $dateformatdetails['dateformat']);
    +                            $goodchars = "0123456789".$goodchars[0];
    +                            $dataentryoutput .= "\t<input type='text' class='popupdate' size='12' name='$fieldname' onkeypress=\"return goodchars(event,'".$goodchars."')\"/>\n";
    +                            $dataentryoutput .= "\t<input type='hidden' name='dateformat{$fieldname}' id='dateformat{$fieldname}' value='{$dateformatdetails['jsdate']}'  />\n";
    +                        }
    +                        else
    +                        {
    +                            $dataentryoutput .= "\t<input type='text' name='$fieldname'/>\n";
    +                        }
                             break;
                         case "G": //GENDER drop-down list
                             $dataentryoutput .= "\t<select name='$fieldname'>\n"
    Index: admin/scripts/admin_core.js
    ===================================================================
    --- admin/scripts/admin_core.js	(revision 9740)
    +++ admin/scripts/admin_core.js	(working copy)
    @@ -4,12 +4,16 @@
         setupAllTabs();
         if(typeof(userdateformat) !== 'undefined') 
         {
    -        $(".popupdate").datepicker({ dateFormat: userdateformat,  
    +        $(".popupdate").each(function(i,e) { 
    +            format=$('#dateformat'+e.name).val();
    +            if(!format) format = userdateformat;
    +            $(e).datepicker({ dateFormat: format,  
                                   showOn: 'button',
                                   changeYear: true, 
                                   changeMonth: true, 
                                   duration: 'fast'
                                 }, $.datepicker.regional[userlanguage]);
    +        });
             $(".popupdatetime").datepicker({ dateFormat: userdateformat+' 00:00',  
                                   showOn: 'button',
                                   changeYear: true, 
    Index: admin/activate_functions.php
    ===================================================================
    --- admin/activate_functions.php	(revision 9740)
    +++ admin/activate_functions.php	(working copy)
    @@ -344,7 +344,7 @@
                     $createsurvey .= " X";
                     break;
                 case "D":  //DATE
    -                $createsurvey .= " D";
    +                $createsurvey .= " T";
                     break;
                 case "5":  //5 Point Choice
                 case "G":  //Gender
    Index: admin/browse.php
    ===================================================================
    --- admin/browse.php	(revision 9740)
    +++ admin/browse.php	(working copy)
    @@ -139,8 +139,6 @@
     
     if ($subaction == "id")
     {
    -    $dateformatdetails=getDateFormatData($_SESSION['dateformat']);
    -
         //SHOW HEADER
         if (!isset($_POST['sql']) || !$_POST['sql']) {$browseoutput .= $surveyoptions;} // Don't show options if coming from tokens script
         //FIRST LETS GET THE NAMES OF THE QUESTIONS AND MATCH THEM TO THE FIELD NAMES FOR THE DATABASE
    @@ -311,7 +309,7 @@
                             $browseoutput .= "";
                     }
                     else
    -                    $browseoutput .= htmlspecialchars(strip_tags(strip_javascript(getextendedanswer($fnames[$i][0], $idrow[$fnames[$i][0]], '', $dateformatdetails['phpdate']))), ENT_QUOTES);
    +                    $browseoutput .= htmlspecialchars(strip_tags(strip_javascript(getextendedanswer($fnames[$i][0], $idrow[$fnames[$i][0]], ''))), ENT_QUOTES);
                 }
                 $browseoutput .= "</td>\n\t</tr>\n";
                 $highlight=!$highlight;
    @@ -883,7 +881,6 @@
                 ."\t</div><form action='$scriptname?action=browse' id='resulttableform' method='post'>\n";
     
         $browseoutput .= $tableheader;
    -    $dateformatdetails=getDateFormatData($_SESSION['dateformat']);
     
         while ($dtrow = $dtresult->FetchRow())
         {
    @@ -932,15 +929,6 @@
     
             for ($i; $i<$fncount; $i++)
             {
    -            $browsedatafield=htmlspecialchars($dtrow[$fnames[$i][0]]);
    -
    -            if ( isset($fnames[$i][4]) && $fnames[$i][4] == 'D' && $fnames[$i][0] != '')
    -            {
    -                if ($dtrow[$fnames[$i][0]] == NULL)
    -                    $browsedatafield = "N";
    -                else
    -                    $browsedatafield = "Y";
    -            }
                 if (isset($fnames[$i]['type']) && $fnames[$i]['type'] == "|")
                 {
                     $index = $fnames[$i]['index'];
    @@ -959,7 +947,20 @@
                         $browseoutput .= "<td align='center'>&nbsp;</td>\n";
                 }
                 else
    +            {
    +                if ( isset($fnames[$i][4]) && $fnames[$i][4] == 'D' && $fnames[$i][0] != '')
    +                {
    +                    if ($dtrow[$fnames[$i][0]] == NULL)
    +                        $browsedatafield = "N";
    +                    else
    +                        $browsedatafield = "Y";
    +                }
    +                else
    +                {
    +                    $browsedatafield = htmlspecialchars(strip_tags(strip_javascript(getextendedanswer($fnames[$i][0], $dtrow[$fnames[$i][0]], ''))), ENT_QUOTES);
    +                }
                     $browseoutput .= "<td align='center'>$browsedatafield</td>\n";
    +            }
             }
             $browseoutput .= "\t</tr>\n";
         }
    @@ -1124,7 +1125,6 @@
                 ."\t</div><form action='$scriptname?action=browse' id='resulttableform' method='post'>\n";
     
         $browseoutput .= $tableheader;
    -    $dateformatdetails=getDateFormatData($_SESSION['dateformat']);
     
         while ($dtrow = $dtresult->FetchRow())
         {
    Index: admin/exportresults.php
    ===================================================================
    --- admin/exportresults.php	(revision 9740)
    +++ admin/exportresults.php	(working copy)
    @@ -1181,6 +1181,14 @@
                         }
     
                         break;
    +                case "D": //DATE
    +                    $qidattributes = getQuestionAttributes($fqid, $ftype);
    +                    $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $thissurvey);
    +                    if(!empty($drow[$i]))
    +                    {
    +                        $exportoutput .= DateTime::createFromFormat("Y-m-d H:i:s", $drow[$i])->format($dateformatdetails['phpdate']);
    +                    }
    +                    break;
     
                     default: $tempresult=$dresult->FetchField($i);
                     if ($tempresult->name == "token")
    @@ -1261,4 +1269,4 @@
             $string = mb_ereg_replace($pattern[$i], '', $string);
         }
         return strip_tags($string);
    -}
    \ No newline at end of file
    +}
    Index: index.php
    ===================================================================
    --- index.php	(revision 9740)
    +++ index.php	(working copy)
    @@ -1784,7 +1784,7 @@
     
     function checkpregs($move,$backok=null)
     {
    -    global $connect, $thisstep;
    +    global $connect, $thisstep, $thissurvey;
         if (!isset($backok) || $backok != "Y")
         {
             global $dbprefix;
    @@ -1849,6 +1849,18 @@
                                 continue;
                             }
                         }
    +                    elseif ($fieldinfo['type'] == 'D')
    +                    {
    +                        // $_SESSION[$fieldinfo['fieldname']] now contains the crappy value parsed by
    +                        // Date_Time_Converter in save.php. We can leave it there. We just do validation here.
    +                        $dateformatdetails = aGetDateFormatDataForQid($qidattributes, $thissurvey);
    +                        $datetimeobj = DateTime::createFromFormat($dateformatdetails['phpdate'], $_POST[$field]);
    +                        if(!$datetimeobj)
    +                        {
    +                            $notvalidated[]=$field;
    +                            continue;
    +                        }
    +                    }
                     }
                 }
             }
    Index: classes/datetimeconverter/class.datetimeconverter.php
    ===================================================================
    --- classes/datetimeconverter/class.datetimeconverter.php	(revision 9740)
    +++ classes/datetimeconverter/class.datetimeconverter.php	(working copy)
    @@ -94,10 +94,10 @@
         private function _default_date_time_units() {
             $this->seconds 		= '00';
             $this->minutes		= '00';
    -        $this->hours		= '12';
    +        $this->hours		= '00';
             $this->days			= '01';
             $this->months		= '01';
    -        $this->years		= date("Y");
    +        $this->years		= '1970';
             $this->ampm			= 'am';
         }
     
    @@ -397,4 +397,4 @@
     
     }
     
    -?>
    \ No newline at end of file
    +?>
    Index: classes/core/surveytranslator.php
    ===================================================================
    --- classes/core/surveytranslator.php	(revision 9740)
    +++ classes/core/surveytranslator.php	(working copy)
    @@ -78,6 +78,158 @@
     }
     
     
    +/**
    + * Convert a 'dateformat' format string to a 'phpdate' format.
    + *
    + * @param $sDateformat string
    + * @returns string
    + *
    + */
    +function sPhpdateFromDateformat($sDateformat)
    +{
    +    // Note that order is relevant (longer strings first)
    +    $aFmts = array(
    +    // With leading zero
    +    "dd"   => "d",
    +    "mm"   => "m",
    +    "yyyy" => "Y",
    +    "HH"   => "H",
    +    "MM"   => "i",
    +    // Without leading zero
    +    "d"    => "j",
    +    "m"    => "n",
    +    "yy"   => "y",
    +    "H"    => "G",
    +    "M"    => "i");
    +
    +    // Extra allowed characters
    +    $aAllowed = array('-', '.', '/', ':', ' ');
    +
    +    // Convert
    +    $tmp = array();
    +    foreach ($aAllowed as $k)
    +    {
    +        $tmp[$k] = true;
    +    }
    +    foreach (array_values($aFmts) as $k)
    +    {
    +        for ($i = 0; $i < strlen($k); $i++)
    +        {
    +            $tmp[$k[$i]] = true;
    +        }
    +    }
    +    $aAllowed = $tmp;
    +
    +    $tmp = strtr($sDateformat, $aFmts);
    +    $sPhpdate = "";
    +    for ($i = 0; $i < strlen($tmp); $i++)
    +    {
    +        $c = $tmp[$i];
    +        if(isset($aAllowed[$c]))
    +        {
    +            $sPhpdate .= $c;
    +        }
    +    }
    +
    +    return $sPhpdate;
    +}
    +
    +
    +/**
    + * Convert a 'dateformat' format string to a 'jsdate' format.
    + *
    + * @param $sDateformat string
    + * @returns string
    + *
    + */
    +function sJsdateFromDateformat($sDateformat)
    +{
    +    // The only difference from dateformat is that Jsdate does not support truncated years
    +    return str_replace("yyyy", "yy", $sDateformat);
    +}
    +
    +
    +/**
    + * Get the date format details for a specific question.
    + *
    + * @param $aQidAttributes array Question attributes
    + * @param $mThisSurvey mixed Array of Survey attributes or surveyid
    + * @returns array
    + *
    + */
    +function aGetDateFormatDataForQid($aQidAttributes, $mThisSurvey)
    +{
    +    if (trim($aQidAttributes['date_format'])!='')
    +    {
    +        $aDateFormatDetails = array();
    +        $aDateFormatDetails['dateformat'] = trim($aQidAttributes['date_format']);
    +        $aDateFormatDetails['phpdate'] = sPhpdateFromDateformat($aDateFormatDetails['dateformat']);
    +        $aDateFormatDetails['jsdate'] = sJsdateFromDateformat($aDateFormatDetails['dateformat']);
    +    }
    +    else
    +    {
    +        if(!is_array($mThisSurvey))
    +        {
    +            $mThisSurvey = array('surveyls_dateformat' => aGetDateFormatForSid($mThisSurvey));
    +        }
    +        $aDateFormatDetails = getDateFormatData($mThisSurvey['surveyls_dateformat']);
    +    }
    +    return $aDateFormatDetails;
    +}
    +
    +
    +/**
    + * Get the date format for a specified survey
    + *
    + * @param $surveyid integer Survey id
    + * @param $languagecode string Survey language code (optional)
    + * @returns integer
    + *
    + */
    +function aGetDateFormatForSid($surveyid, $languagecode='')
    +{
    +    global $connect;
    +    if (!isset($languagecode) || $languagecode=='')
    +    {
    +        $languagecode=GetBaseLanguageFromSurveyID($surveyid);;
    +    }
    +    $query = "SELECT surveyls_dateformat FROM ".db_table_name('surveys').",".db_table_name('surveys_languagesettings')." WHERE sid=$surveyid and surveyls_survey_id=$surveyid and surveyls_language='$languagecode'";
    +    $dateformat = $connect->GetOne($query);
    +    if(is_null($dateformat))
    +    {
    +        $dateformat = 0;
    +    }
    +    return $dateformat;
    +}
    +
    +
    +/**
    + * Check whether we can show the JS date picker with the current format
    + *
    + * @param $dateformatdetails array Date format details for the question
    + * @param $dateformats array Available date formats
    + * @returns integer
    + *
    + */
    +function bCanShowDatePicker($dateformatdetails, $dateformats=null)
    +{
    +    if(is_null($dateformats))
    +    {
    +        $dateformats = getDateFormatData();
    +    }
    +    $showpicker = false;
    +    foreach($dateformats as $format)
    +    {
    +        if($format['jsdate'] == $dateformatdetails['jsdate'])
    +        {
    +            $showpicker = true;
    +            break;
    +        }
    +    }
    +    return $showpicker;
    +}
    +
    +
     function getLanguageCodefromLanguage($languagetosearch)
     {
         $detaillanguages = getLanguageData();
    
    patch file icon datetime.patch (43,384 bytes) 2011-02-04 16:01 +
  • ? file icon limesurvey_survey_59376.lss (30,095 bytes) 2011-02-04 16:02

-Relationships
+Relationships

-Notes

~13632

c_schmitz (administrator)

Hi Yuri,

why did you create a separate question type for that. Wouldn't it be better to extend the existin date question type?

~13664

user9586

Cut&pasting our conversation here for reference:

Am 29.11.2010 11:14, schrieb Yuri D'Elia:
> On Mon, 29 Nov 2010 11:06:19 +0100
> Carsten Schmitz<carsten.schmitz@limeservice.com> wrote:
>
>> Hello Yuri,
>>
>> year/month date can still be stored, the day would just point to the 1st
>> of the month and tim set to midnight, same for the other examples.
>> The information which of the stored bits is lastly used, can be
>> retrieved from the question configuration.
>> That way a survey admin could even change the format during a survey
>> without messing everything up.
>> And it would still be more easily evaluatable in statistics.
> Basically, you'd suggest to use the format as a mask.
> I didn't think of that, but I will try to extend the 'date' type (I cloned the 'date' code anyway).
>
That would be great.
> Instead of using the fixed time format array I wrote a couple of functions that translate a phpdate to jsdate/etc. There are some heavy changes to the javascript at runtime, but I think that's feasible. As long as I use the default survey's time format, it should be backward compatible.
>
Have a look at the existing date converter function - it is pretty
powerful. I'd guess it is all you need. (except for time combinations)

> Does that sound better?
>
> I have no clue however about what it means for the statistics part, since the format will have to be taken into account differently.

Yeah, I guess to be fast on the evaluation part we will have to use DB
type specific date handling routines if necessary.


Best regards from Hamburg/Germany

Carsten Schmitz

~14052

user9586

I've finished the revised implementation of the 'DATE' question type.

As discussed with Carsten, instead of adding a new question type I added a new
question attribute to the 'D' (Date) question type: date_format.

As the name implies, date_format is a user-customizable date format entered
with the existing "dateformat" specifiers (y/yy d/dd m/mm H/HH M/MM). If a date
format is not specified for a question, it is taken from the survey default.

Internally, the date is now kept as a 'Y-m-d H:i:s' timestamp. When posted, the
date is validated according to the question format, then converted to a
timestamp. When presented, the answer is formatted again with the user supplied
format. When a survey is active, the question column is now a timestamp instead
of a date. This is completely transparent and (according to my tests) also
retrocompatibile with old activated surveys.

For a date field, the popup date picker is only show if the date contains the
day/month/years parts. If a date is partial (containing only hours/minutes, for
example), the date picker is not shown. The accepted characters work according
to the format too.

When dropdown boxes are enabled, the boxes are constructed dynamically with the
specified format, in the same order as the format.

Dropdown dates also have two new attributes: dropdown_dates_minute_step and
dropdown_dates_month_style.

minute_step allows to display minutes with the specified time increment (so you
can have 5/10/15 minutes increment instead of displaying a full list of 60
numbers).

Month_style allows full month names or abbreviated month names to be shown.

I've also modified the code for the dataentry screen. The result here is
suboptimal, since for non-standard date specifiers, the popup calendar cannot
be shown, and the date format is not visible as a hint to the user. Here a
little text showing the format of the date would help. Note that however, for
standard date formats the popup calendar is shown as before, so existing
behavior is *unchanged*.

I've fixed the export for csv/excel/word formats. Here the timestamp is
formatted according to the date format.

The export for spss and R however will show a full timestamp. I think that's
acceptable as a starting point, but I don't have enough knowledge for those
formats to fix it.

I've attached a sample survey to test the various format types and screens.

The patch was done against limesurvey (stable from SVN, version 09740), but it
applies cleanly also to limesurvey_dev.

I've also renamed the "Date" description to "Date/time" in the question-type
dropdown, since I often used this question type to store minutes, months,
hours:minutes and several combinations.

I think that's very flexible.

~14475

user9586

I also successfully ported this patch to the stable branch (currenctly limesurvey#r9891. Please let me know if you are interested for the next RC.

~14582

c_schmitz (administrator)

wavexx, thank you but it way too late now to get this into 1.91. It will definately go into 1.92.

~14837

c_schmitz (administrator)

Wavexx, can you please commtt this patch to the _dev branch at
https://limesurvey.svn.sourceforge.net/svnroot/limesurvey/source/limesurvey_dev

~14851

user9586

Ok, committed into 10017.
The previously attached survey should be a good test.
+Notes

-Issue History
Date Modified Username Field Change
2010-11-26 18:21 user9586 New Issue
2010-11-27 19:52 c_schmitz Note Added: 13632
2010-11-29 13:33 user9586 Note Added: 13664
2010-12-11 14:00 c_schmitz Assigned To => user9586
2010-12-11 14:00 c_schmitz Status new => feedback
2011-02-04 16:01 user9586 File Added: datetime.patch
2011-02-04 16:02 user9586 File Added: limesurvey_survey_59376.lss
2011-02-04 16:24 user9586 Note Added: 14052
2011-02-04 16:24 user9586 Status feedback => assigned
2011-02-04 16:25 user9586 Assigned To user9586 => c_schmitz
2011-03-20 12:51 user9586 Note Added: 14475
2011-03-28 02:31 c_schmitz Note Added: 14582
2011-04-17 16:28 c_schmitz Note Added: 14837
2011-04-17 16:28 c_schmitz Assigned To c_schmitz => user9586
2011-04-20 13:00 user9586 Note Added: 14851
2011-04-20 13:01 user9586 Assigned To user9586 => c_schmitz
2011-05-07 11:59 c_schmitz Status assigned => resolved
2011-05-07 11:59 c_schmitz Fixed in Version => 2.00
2011-05-07 11:59 c_schmitz Resolution open => fixed
2012-06-21 13:22 c_schmitz Status resolved => closed
+Issue History