{#
/**
 * Date Html, selector style :
 * @var $name
 * @var $qid
 * @var $iLength
 * @var $dateoutput
 * @var $mindate
 * @var $maxdate
 * @var $dateformatdetails
 * @var $dateformatdetailsjs
 * @var $goodchars
 * @var $checkconditionFunction
 * @var $language
 * @var $hidetip
 */
#}

<!-- Date, selector layout -->

<!-- answer -->
<div class='form-inline'>
    <div class='{{coreClass}} form-group'>
        <label for='answer{{name}}' class='sr-only control-label'>
            {{ sprintf(gT('Date format: %s'), dateformatdetails) }}
        </label>
        <div id="answer{{name}}_datetimepicker" class="input-group answer-item date-timepicker-group" data-basename="{{name}}"><!-- data-basename used in js function -->
            {{ C.Html.textField(name,dateoutput,{
                'id' : "answer" ~ name,
                'class' : "form-control date-control date",
                'aria-describedby' : "ls-question-text-" ~ name,
            }) }}
            <div class="input-group-addon btn btn-primary">
                <i class="fa fa-calendar" aria-hidden="true"></i><span class="sr-only"> {{ gT("Open date/time selector") }}</span>
            </div>
        </div>
        {% if(hidetip) %}
        <p class="tip help-block" aria-hidden='true'>
           {{ sprintf(gT('Format: %s'),dateformatdetails) }}
        </p>
        {% endif %}
    </div>
</div>

<div class='hidden' style='display:none'>
    <!-- Obs: No spaces in the div - it will mess up Javascript string parsing -->
    <div id='datemin{{name}}'>{{ mindate }}</div>
    <div id='datemax{{name}}'>{{ maxdate }}</div>
    <div id='dateformat{{name}}'>{{ dateformatdetailsjs }}</div>
</div>

    {#  Set option for launch, can not set to default : maybe more than one datetimepicker in page  #}
    {# get the same default value than qanda_helper #}
    {% set aJsonOption = json_encode({
            'format' : dateformatdetailsjs,
            'minDate' : '{' in mindate ? '1900-01-01' : mindate,
            'maxDate' : '{' in maxdate ? '2037-12-31' : maxdate,
            'stepping' : minuteStep,
            'sideBySide' :  true
        })
    %}
    
    {{ registerScript("doDatetimepicker_" ~ name, "jQuery('#answer" ~ name ~ "_datetimepicker').datetimepicker(" ~ aJsonOption ~ ");" , 'POS_POSTSCRIPT' ) }}
    {# Min and max date sets default value, so use this to override it #}
    {{ registerScript("resetDate" ~ name,"$('#answer" ~ name ~ "').val('" ~ dateoutput ~ "');", 'POS_POSTSCRIPT') }}
    
<!-- end of answer -->
