This repository was archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathdatetime.html.twig
More file actions
39 lines (35 loc) · 1.35 KB
/
datetime.html.twig
File metadata and controls
39 lines (35 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{##
# This file is part of the SgDatatablesBundle package.
#
# (c) stwe <https://github.com/stwe/DatatablesBundle>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#}
{%- set datetime_id_selector -%}
sg-datatables-{{ datatable_name }}-datetime-{{ row_id }}
{%- endset -%}
{%- set datetime_selector -%}
id="{{ datetime_id_selector }}"
{%- endset -%}
{% if column_class_editable_selector is defined %}
<span {{ datetime_selector }} class="{{ datetime_id_selector }} {{ column_class_editable_selector }}" data-pk="{{ pk }}" {% if path is not same as(null) %}data-path="{{ path }}"{% endif %}></span>
{% else %}
<span {{ datetime_selector }} class="{{ datetime_id_selector }}">
{% if data is same as(null) and default_content is not same as(null) %}
{{ default_content }}
{% endif %}
</span>
{% endif %}
{% if data is not same as(null) %}
<script type="text/javascript">
$(function() {
moment.locale("{{ app.request.locale }}");
{% if timeago is same as(false) %}
$(".{{ datetime_id_selector }}").html(moment.unix({{ data|date('U') }}).format("{{ date_format }}"));
{% else %}
$(".{{ datetime_id_selector }}").html(moment.unix({{ data|date('U') }}).fromNow());
{% endif %}
});
</script>
{% endif %}