<commit_before>{% extends "forms/field.html.twig" %}

{% set default_php_dateformat = "d-m-Y H:i" %}
{% set php_dateformat = config.system.pages.dateformat.default ?: default_php_dateformat %}
{% set js_dateformat = admin.dateformatToMomentJS(php_dateformat) %}
{% set value = (value is null ? field.default : value) %}
{% set value = (value is null ? value : value|date(php_dateformat)) %}

{% block input %}
<div class="form-input-wrapper datetime-picker-wrapper {{ field.size }}">
    <input
            name="{{ (scope ~ field.name)|fieldName }}"
            value="{{ value|raw|join(', ') }}"
            {% block input_attributes %}
                type="text"
                data-grav-datetime="{{ {'format': js_dateformat} | json_encode | e('html_attr') }}"
                {% if field.validate.min %}min="{{ (field.validate.min is null ? field.validate.min : field.validate.min|date(php_dateformat)) }}"{% endif %}
                {% if field.validate.max %}max="{{ (field.validate.max is null ? field.validate.max : field.validate.max|date(php_dateformat)) }}"{% endif %}
                {{ parent() }}
            {% endblock %}
    />
    <span class="field-icons">
        <i class="fa fa-fw fa-calendar"></i>
    </span>
</div>
{% endblock %}
<commit_msg>Better automatic guess for page date formats (#565)<commit_after>{% extends "forms/field.html.twig" %}

{% set default_php_dateformat = "d-m-Y H:i" %}

{% if not config.system.pages.dateformat.default and value %}
    {% if value|split('/')|count %}{% set default_php_dateformat = 'm/d/Y H:i' %}{% endif %}
    {% if value|split('-')|first > 12 %}{% set default_php_dateformat = 'y-m-d H:i' %}{% endif %}
{% endif %}

{% set php_dateformat = config.system.pages.dateformat.default ?: default_php_dateformat %}
{% set js_dateformat = admin.dateformatToMomentJS(php_dateformat) %}
{% set value = (value is null ? field.default : value) %}
{% set value = (value is null ? value : value|date(php_dateformat)) %}

{% block input %}
<div class="form-input-wrapper datetime-picker-wrapper {{ field.size }}">
    <input
            name="{{ (scope ~ field.name)|fieldName }}"
            value="{{ value|raw|join(', ') }}"
            {% block input_attributes %}
                type="text"
                data-grav-datetime="{{ {'format': js_dateformat} | json_encode | e('html_attr') }}"
                {% if field.validate.min %}min="{{ (field.validate.min is null ? field.validate.min : field.validate.min|date(php_dateformat)) }}"{% endif %}
                {% if field.validate.max %}max="{{ (field.validate.max is null ? field.validate.max : field.validate.max|date(php_dateformat)) }}"{% endif %}
                {{ parent() }}
            {% endblock %}
    />
    <span class="field-icons">
        <i class="fa fa-fw fa-calendar"></i>
    </span>
</div>
{% endblock %}

{'fraction_non_alphanumeric': 0.18699472759226712, 'fraction_numerical': 0.0017574692442882249, 'mean_word_length': 2.997191011235955, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6719482', 'n_tokens_mistral': 959, 'n_tokens_neox': 870, 'n_words': 182}