We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Date de publication future des News
Bonjour,

Ça ne regarde certainement que moi mais...

![2019-08-03-073538_1920x1080_scrot](https://user-images.githubusercontent.com/2202307/62408818-98070c80-b5ce-11e9-9a0c-39bf3e585761.png)

C'est pas logique.  « Dans le futur » n'apporte **aucune information utile**. L’intérêt des news c'est d'avoir la date future, pour pouvoir géré et vérifier que la publication sera à la bonne date. Là, il faut ouvrir la news, et lire la date dans un format cryptique.

![2019-08-03-091429_1920x1080_scrot](https://user-images.githubusercontent.com/2202307/62408845-28dde800-b5cf-11e9-8dbd-c01a7fcaa46b.png)

Il y a certainement plus claire comme format.

C'est tellement compliqué qu'au final, j'écris juste tout dans un fichier ou sur un boue de papier.

Quand les 10 prochains contenus sont marqués « Dans le futur » franchement on a le sentiment d'être pris pour un crétin par l'IHM.

______________________


Bref, c'est géré par la fonction `format_date`.  
À votre avis comment on pourrait faire pour améliorer ça ?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `zds/featured/forms.py`
Content:
```
1 from crispy_forms.bootstrap import StrictButton
2 from crispy_forms.helper import FormHelper
3 from crispy_forms.layout import Layout, Field, ButtonHolder
4 from django import forms
5 from django.urls import reverse
6 from django.utils.translation import ugettext_lazy as _
7 
8 from zds.featured.models import FeaturedResource, FeaturedMessage
9 
10 
11 class FeaturedResourceForm(forms.ModelForm):
12     class Meta:
13         model = FeaturedResource
14 
15         fields = ['title', 'type', 'authors', 'image_url', 'url']
16 
17         widgets = {
18             'title': forms.TextInput(
19                 attrs={
20                     'placeholder': _('Titre de la Une')
21                 }
22             ),
23 
24             'type': forms.TextInput(
25                 attrs={
26                     'placeholder': _('ex: Un projet, Un article, Un tutoriel...')
27                 }
28             ),
29 
30             'authors': forms.TextInput(
31                 attrs={
32                     'placeholder': _('Des auteurs (ou pas) ?')
33                 }
34             ),
35 
36             'image_url': forms.URLInput(
37                 attrs={
38                     'placeholder': _('Lien vers l\'image de la Une (dimensions: 228x228px).')
39                 }
40             ),
41 
42             'url': forms.URLInput(
43                 attrs={
44                     'placeholder': _('Lien vers la ressource.')
45                 }
46             )
47         }
48 
49     major_update = forms.BooleanField(
50         label=_('Mise à jour majeure (fera passer la Une en première position lors d\'un changement)'),
51         initial=False,
52         required=False
53     )
54 
55     pubdate = forms.DateTimeField(
56         label=_('Date de publication (exemple: 25/12/2015 15:00 ou 2015-12-25T15:00)'),
57         input_formats=[
58             '%d/%m/%Y %H:%M:%S', '%Y-%m-%d %H:%M:%S',  # full format with second
59             '%Y-%m-%dT%H:%M',  # datetime field format
60             '%Y-%m-%d %H:%M', '%d/%m/%Y %H:%M',  # without second
61             '%Y-%m-%d', '%d/%m/%Y'  # day only
62         ],
63         widget=forms.DateTimeInput(
64             attrs={'placeholder': _('Exemple : 25/12/2016 10:00'), 'type': 'datetime-local'},
65             format='%Y-%m-%dT%H:%M'  # datetime field format
66         )
67     )
68 
69     request = forms.IntegerField(widget=forms.HiddenInput(), required=False)
70 
71     def __init__(self, *args, **kwargs):
72         hide_major_update_field = kwargs.pop('hide_major_update_field', False)
73 
74         super(FeaturedResourceForm, self).__init__(*args, **kwargs)
75         self.helper = FormHelper()
76         self.helper.form_class = 'content-wrapper'
77         self.helper.form_method = 'post'
78         self.helper.form_action = reverse('featured-resource-create')
79 
80         fields = [
81             Field('request'),
82             Field('title'),
83             Field('type'),
84             Field('authors'),
85             Field('image_url'),
86             Field('url')
87         ]
88 
89         if not hide_major_update_field:
90             fields.append(Field('major_update'))
91 
92         fields.extend([
93             Field('pubdate'),
94             ButtonHolder(
95                 StrictButton(_('Enregistrer'), type='submit'),
96             )
97         ])
98 
99         self.helper.layout = Layout(*fields)
100 
101 
102 class FeaturedMessageForm(forms.ModelForm):
103     class Meta:
104         model = FeaturedMessage
105 
106         fields = ['hook', 'message', 'url']
107 
108         widgets = {
109             'hook': forms.TextInput(
110                 attrs={
111                     'placeholder': _('Mot d\'accroche court ("Nouveau !")')
112                 }
113             ),
114 
115             'message': forms.TextInput(
116                 attrs={
117                     'placeholder': _('Message à afficher')
118                 }
119             ),
120 
121             'url': forms.URLInput(
122                 attrs={
123                     'placeholder': _('Lien vers la description de la ressource')
124                 }
125             )
126         }
127 
128     def __init__(self, *args, **kwargs):
129         super(FeaturedMessageForm, self).__init__(*args, **kwargs)
130         self.helper = FormHelper()
131         self.helper.form_class = 'content-wrapper'
132         self.helper.form_method = 'post'
133         self.helper.form_action = reverse('featured-message-create')
134 
135         self.helper.layout = Layout(
136             Field('hook'),
137             Field('message'),
138             Field('url'),
139             ButtonHolder(
140                 StrictButton(_('Enregistrer'), type='submit'),
141             ),
142         )
143
```

Path: `zds/utils/templatetags/date.py`
Content:
```
1 from datetime import datetime, timedelta
2 
3 from django import template
4 from django.contrib.humanize.templatetags.humanize import naturaltime
5 from django.template.defaultfilters import date
6 from django.utils.timezone import get_default_timezone
7 from django.utils.translation import ugettext_lazy as _
8 
9 register = template.Library()
10 
11 """
12 Define a filter to format date.
13 """
14 
15 # Date formatting constants
16 
17 __DATE_FMT_FUTUR = _('Dans le futur')
18 __ABS_DATE_FMT_SMALL = _(r'd/m/y à H\hi')       # Small format
19 __ABS_DATE_FMT_NORMAL = _(r'l d F Y à H\hi')    # Normal format
20 __ABS_HUMAN_TIME_FMT = _('%d %b %Y, %H:%M:%S')
21 
22 
23 def date_formatter(value, tooltip, small):
24     """
25     Format a date to an human readable string.
26 
27     :param value: Date to format.
28     :param bool tooltip: if `True`, format date to a tooltip label.
29     :param bool small: if `True`, create a shorter string.
30     :return:
31     """
32     if not isinstance(value, datetime):
33         return value
34 
35     if getattr(value, 'tzinfo', None):
36         now = datetime.now(get_default_timezone())
37     else:
38         now = datetime.now()
39     now = now - timedelta(microseconds=now.microsecond)
40 
41     if value > now:
42         return __DATE_FMT_FUTUR
43     else:
44         delta = now - value
45         # Natural time for today, absolute date after.
46         # Reverse if in tooltip
47         if (delta.days == 0) != tooltip:
48             return naturaltime(value)
49         else:
50             return date(value, str(__ABS_DATE_FMT_SMALL if small else __ABS_DATE_FMT_NORMAL))
51 
52 
53 @register.filter
54 def format_date(value, small=False):
55     """Format a date to an human readable string."""
56     return date_formatter(value, tooltip=False, small=small)
57 
58 
59 @register.filter
60 def tooltip_date(value):
61     """Format a date to an human readable string. To be used in tooltip."""
62     return date_formatter(value, tooltip=True, small=False)
63 
64 
65 @register.filter
66 def humane_time(timestamp):
67     """Render time (number of second from epoch) to an human readable string"""
68     return format_date(datetime.fromtimestamp(timestamp))
69 
70 
71 @register.filter
72 def from_elasticsearch_date(value):
73     try:
74         date = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%f')
75     except ValueError:
76         date = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')
77     return date
78
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/zds/featured/forms.py b/zds/featured/forms.py
--- a/zds/featured/forms.py
+++ b/zds/featured/forms.py
@@ -61,8 +61,8 @@
             '%Y-%m-%d', '%d/%m/%Y'  # day only
         ],
         widget=forms.DateTimeInput(
-            attrs={'placeholder': _('Exemple : 25/12/2016 10:00'), 'type': 'datetime-local'},
-            format='%Y-%m-%dT%H:%M'  # datetime field format
+            attrs={'placeholder': _('Exemple : 25/12/2016 10:00'), 'type': 'text'},
+            format='%d/%m/%Y %H:%M'  # datetime field format
         )
     )
 
diff --git a/zds/utils/templatetags/date.py b/zds/utils/templatetags/date.py
--- a/zds/utils/templatetags/date.py
+++ b/zds/utils/templatetags/date.py
@@ -20,7 +20,7 @@
 __ABS_HUMAN_TIME_FMT = _('%d %b %Y, %H:%M:%S')
 
 
-def date_formatter(value, tooltip, small):
+def date_formatter(value, tooltip, small, ignore_future=False):
     """
     Format a date to an human readable string.
 
@@ -38,7 +38,7 @@
         now = datetime.now()
     now = now - timedelta(microseconds=now.microsecond)
 
-    if value > now:
+    if value > now and not ignore_future:
         return __DATE_FMT_FUTUR
     else:
         delta = now - value
@@ -52,10 +52,22 @@
 
 @register.filter
 def format_date(value, small=False):
-    """Format a date to an human readable string."""
+    """
+    Format a date to an human readable string.
+    If ``value`` is in future it is replaced by "In the future".
+    """
     return date_formatter(value, tooltip=False, small=small)
 
 
+@register.filter
+def format_date_no_future(value):
+    """
+    Format a date to an human readable string.
+    If ``value`` is in future it is formatted as a normal date.
+    """
+    return date_formatter(value, tooltip=False, small=True, ignore_future=True)
+
+
 @register.filter
 def tooltip_date(value):
     """Format a date to an human readable string. To be used in tooltip."""

{"golden_diff": "diff --git a/zds/featured/forms.py b/zds/featured/forms.py\n--- a/zds/featured/forms.py\n+++ b/zds/featured/forms.py\n@@ -61,8 +61,8 @@\n             '%Y-%m-%d', '%d/%m/%Y'  # day only\n         ],\n         widget=forms.DateTimeInput(\n-            attrs={'placeholder': _('Exemple : 25/12/2016 10:00'), 'type': 'datetime-local'},\n-            format='%Y-%m-%dT%H:%M'  # datetime field format\n+            attrs={'placeholder': _('Exemple : 25/12/2016 10:00'), 'type': 'text'},\n+            format='%d/%m/%Y %H:%M'  # datetime field format\n         )\n     )\n \ndiff --git a/zds/utils/templatetags/date.py b/zds/utils/templatetags/date.py\n--- a/zds/utils/templatetags/date.py\n+++ b/zds/utils/templatetags/date.py\n@@ -20,7 +20,7 @@\n __ABS_HUMAN_TIME_FMT = _('%d %b %Y, %H:%M:%S')\n \n \n-def date_formatter(value, tooltip, small):\n+def date_formatter(value, tooltip, small, ignore_future=False):\n     \"\"\"\n     Format a date to an human readable string.\n \n@@ -38,7 +38,7 @@\n         now = datetime.now()\n     now = now - timedelta(microseconds=now.microsecond)\n \n-    if value > now:\n+    if value > now and not ignore_future:\n         return __DATE_FMT_FUTUR\n     else:\n         delta = now - value\n@@ -52,10 +52,22 @@\n \n @register.filter\n def format_date(value, small=False):\n-    \"\"\"Format a date to an human readable string.\"\"\"\n+    \"\"\"\n+    Format a date to an human readable string.\n+    If ``value`` is in future it is replaced by \"In the future\".\n+    \"\"\"\n     return date_formatter(value, tooltip=False, small=small)\n \n \n+@register.filter\n+def format_date_no_future(value):\n+    \"\"\"\n+    Format a date to an human readable string.\n+    If ``value`` is in future it is formatted as a normal date.\n+    \"\"\"\n+    return date_formatter(value, tooltip=False, small=True, ignore_future=True)\n+\n+\n @register.filter\n def tooltip_date(value):\n     \"\"\"Format a date to an human readable string. To be used in tooltip.\"\"\"\n", "issue": "Date de publication future des News\nBonjour,\r\n\r\n\u00c7a ne regarde certainement que moi mais...\r\n\r\n![2019-08-03-073538_1920x1080_scrot](https://user-images.githubusercontent.com/2202307/62408818-98070c80-b5ce-11e9-9a0c-39bf3e585761.png)\r\n\r\nC'est pas logique.  \u00ab Dans le futur \u00bb n'apporte **aucune information utile**. L\u2019int\u00e9r\u00eat des news c'est d'avoir la date future, pour pouvoir g\u00e9r\u00e9 et v\u00e9rifier que la publication sera \u00e0 la bonne date. L\u00e0, il faut ouvrir la news, et lire la date dans un format cryptique.\r\n\r\n![2019-08-03-091429_1920x1080_scrot](https://user-images.githubusercontent.com/2202307/62408845-28dde800-b5cf-11e9-8dbd-c01a7fcaa46b.png)\r\n\r\nIl y a certainement plus claire comme format.\r\n\r\nC'est tellement compliqu\u00e9 qu'au final, j'\u00e9cris juste tout dans un fichier ou sur un boue de papier.\r\n\r\nQuand les 10 prochains contenus sont marqu\u00e9s \u00ab Dans le futur \u00bb franchement on a le sentiment d'\u00eatre pris pour un cr\u00e9tin par l'IHM.\r\n\r\n______________________\r\n\r\n\r\nBref, c'est g\u00e9r\u00e9 par la fonction `format_date`.  \r\n\u00c0 votre avis comment on pourrait faire pour am\u00e9liorer \u00e7a ?\n", "before_files": [{"content": "from crispy_forms.bootstrap import StrictButton\nfrom crispy_forms.helper import FormHelper\nfrom crispy_forms.layout import Layout, Field, ButtonHolder\nfrom django import forms\nfrom django.urls import reverse\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom zds.featured.models import FeaturedResource, FeaturedMessage\n\n\nclass FeaturedResourceForm(forms.ModelForm):\n    class Meta:\n        model = FeaturedResource\n\n        fields = ['title', 'type', 'authors', 'image_url', 'url']\n\n        widgets = {\n            'title': forms.TextInput(\n                attrs={\n                    'placeholder': _('Titre de la Une')\n                }\n            ),\n\n            'type': forms.TextInput(\n                attrs={\n                    'placeholder': _('ex: Un projet, Un article, Un tutoriel...')\n                }\n            ),\n\n            'authors': forms.TextInput(\n                attrs={\n                    'placeholder': _('Des auteurs (ou pas)\u00a0?')\n                }\n            ),\n\n            'image_url': forms.URLInput(\n                attrs={\n                    'placeholder': _('Lien vers l\\'image de la Une (dimensions: 228x228px).')\n                }\n            ),\n\n            'url': forms.URLInput(\n                attrs={\n                    'placeholder': _('Lien vers la ressource.')\n                }\n            )\n        }\n\n    major_update = forms.BooleanField(\n        label=_('Mise \u00e0 jour majeure (fera passer la Une en premi\u00e8re position lors d\\'un changement)'),\n        initial=False,\n        required=False\n    )\n\n    pubdate = forms.DateTimeField(\n        label=_('Date de publication (exemple: 25/12/2015 15:00 ou 2015-12-25T15:00)'),\n        input_formats=[\n            '%d/%m/%Y %H:%M:%S', '%Y-%m-%d %H:%M:%S',  # full format with second\n            '%Y-%m-%dT%H:%M',  # datetime field format\n            '%Y-%m-%d %H:%M', '%d/%m/%Y %H:%M',  # without second\n            '%Y-%m-%d', '%d/%m/%Y'  # day only\n        ],\n        widget=forms.DateTimeInput(\n            attrs={'placeholder': _('Exemple : 25/12/2016 10:00'), 'type': 'datetime-local'},\n            format='%Y-%m-%dT%H:%M'  # datetime field format\n        )\n    )\n\n    request = forms.IntegerField(widget=forms.HiddenInput(), required=False)\n\n    def __init__(self, *args, **kwargs):\n        hide_major_update_field = kwargs.pop('hide_major_update_field', False)\n\n        super(FeaturedResourceForm, self).__init__(*args, **kwargs)\n        self.helper = FormHelper()\n        self.helper.form_class = 'content-wrapper'\n        self.helper.form_method = 'post'\n        self.helper.form_action = reverse('featured-resource-create')\n\n        fields = [\n            Field('request'),\n            Field('title'),\n            Field('type'),\n            Field('authors'),\n            Field('image_url'),\n            Field('url')\n        ]\n\n        if not hide_major_update_field:\n            fields.append(Field('major_update'))\n\n        fields.extend([\n            Field('pubdate'),\n            ButtonHolder(\n                StrictButton(_('Enregistrer'), type='submit'),\n            )\n        ])\n\n        self.helper.layout = Layout(*fields)\n\n\nclass FeaturedMessageForm(forms.ModelForm):\n    class Meta:\n        model = FeaturedMessage\n\n        fields = ['hook', 'message', 'url']\n\n        widgets = {\n            'hook': forms.TextInput(\n                attrs={\n                    'placeholder': _('Mot d\\'accroche court (\"Nouveau\u00a0!\")')\n                }\n            ),\n\n            'message': forms.TextInput(\n                attrs={\n                    'placeholder': _('Message \u00e0 afficher')\n                }\n            ),\n\n            'url': forms.URLInput(\n                attrs={\n                    'placeholder': _('Lien vers la description de la ressource')\n                }\n            )\n        }\n\n    def __init__(self, *args, **kwargs):\n        super(FeaturedMessageForm, self).__init__(*args, **kwargs)\n        self.helper = FormHelper()\n        self.helper.form_class = 'content-wrapper'\n        self.helper.form_method = 'post'\n        self.helper.form_action = reverse('featured-message-create')\n\n        self.helper.layout = Layout(\n            Field('hook'),\n            Field('message'),\n            Field('url'),\n            ButtonHolder(\n                StrictButton(_('Enregistrer'), type='submit'),\n            ),\n        )\n", "path": "zds/featured/forms.py"}, {"content": "from datetime import datetime, timedelta\n\nfrom django import template\nfrom django.contrib.humanize.templatetags.humanize import naturaltime\nfrom django.template.defaultfilters import date\nfrom django.utils.timezone import get_default_timezone\nfrom django.utils.translation import ugettext_lazy as _\n\nregister = template.Library()\n\n\"\"\"\nDefine a filter to format date.\n\"\"\"\n\n# Date formatting constants\n\n__DATE_FMT_FUTUR = _('Dans le futur')\n__ABS_DATE_FMT_SMALL = _(r'd/m/y \u00e0 H\\hi')       # Small format\n__ABS_DATE_FMT_NORMAL = _(r'l d F Y \u00e0 H\\hi')    # Normal format\n__ABS_HUMAN_TIME_FMT = _('%d %b %Y, %H:%M:%S')\n\n\ndef date_formatter(value, tooltip, small):\n    \"\"\"\n    Format a date to an human readable string.\n\n    :param value: Date to format.\n    :param bool tooltip: if `True`, format date to a tooltip label.\n    :param bool small: if `True`, create a shorter string.\n    :return:\n    \"\"\"\n    if not isinstance(value, datetime):\n        return value\n\n    if getattr(value, 'tzinfo', None):\n        now = datetime.now(get_default_timezone())\n    else:\n        now = datetime.now()\n    now = now - timedelta(microseconds=now.microsecond)\n\n    if value > now:\n        return __DATE_FMT_FUTUR\n    else:\n        delta = now - value\n        # Natural time for today, absolute date after.\n        # Reverse if in tooltip\n        if (delta.days == 0) != tooltip:\n            return naturaltime(value)\n        else:\n            return date(value, str(__ABS_DATE_FMT_SMALL if small else __ABS_DATE_FMT_NORMAL))\n\n\n@register.filter\ndef format_date(value, small=False):\n    \"\"\"Format a date to an human readable string.\"\"\"\n    return date_formatter(value, tooltip=False, small=small)\n\n\n@register.filter\ndef tooltip_date(value):\n    \"\"\"Format a date to an human readable string. To be used in tooltip.\"\"\"\n    return date_formatter(value, tooltip=True, small=False)\n\n\n@register.filter\ndef humane_time(timestamp):\n    \"\"\"Render time (number of second from epoch) to an human readable string\"\"\"\n    return format_date(datetime.fromtimestamp(timestamp))\n\n\n@register.filter\ndef from_elasticsearch_date(value):\n    try:\n        date = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%f')\n    except ValueError:\n        date = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')\n    return date\n", "path": "zds/utils/templatetags/date.py"}], "after_files": [{"content": "from crispy_forms.bootstrap import StrictButton\nfrom crispy_forms.helper import FormHelper\nfrom crispy_forms.layout import Layout, Field, ButtonHolder\nfrom django import forms\nfrom django.urls import reverse\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom zds.featured.models import FeaturedResource, FeaturedMessage\n\n\nclass FeaturedResourceForm(forms.ModelForm):\n    class Meta:\n        model = FeaturedResource\n\n        fields = ['title', 'type', 'authors', 'image_url', 'url']\n\n        widgets = {\n            'title': forms.TextInput(\n                attrs={\n                    'placeholder': _('Titre de la Une')\n                }\n            ),\n\n            'type': forms.TextInput(\n                attrs={\n                    'placeholder': _('ex: Un projet, Un article, Un tutoriel...')\n                }\n            ),\n\n            'authors': forms.TextInput(\n                attrs={\n                    'placeholder': _('Des auteurs (ou pas)\u00a0?')\n                }\n            ),\n\n            'image_url': forms.URLInput(\n                attrs={\n                    'placeholder': _('Lien vers l\\'image de la Une (dimensions: 228x228px).')\n                }\n            ),\n\n            'url': forms.URLInput(\n                attrs={\n                    'placeholder': _('Lien vers la ressource.')\n                }\n            )\n        }\n\n    major_update = forms.BooleanField(\n        label=_('Mise \u00e0 jour majeure (fera passer la Une en premi\u00e8re position lors d\\'un changement)'),\n        initial=False,\n        required=False\n    )\n\n    pubdate = forms.DateTimeField(\n        label=_('Date de publication (exemple: 25/12/2015 15:00 ou 2015-12-25T15:00)'),\n        input_formats=[\n            '%d/%m/%Y %H:%M:%S', '%Y-%m-%d %H:%M:%S',  # full format with second\n            '%Y-%m-%dT%H:%M',  # datetime field format\n            '%Y-%m-%d %H:%M', '%d/%m/%Y %H:%M',  # without second\n            '%Y-%m-%d', '%d/%m/%Y'  # day only\n        ],\n        widget=forms.DateTimeInput(\n            attrs={'placeholder': _('Exemple : 25/12/2016 10:00'), 'type': 'text'},\n            format='%d/%m/%Y %H:%M'  # datetime field format\n        )\n    )\n\n    request = forms.IntegerField(widget=forms.HiddenInput(), required=False)\n\n    def __init__(self, *args, **kwargs):\n        hide_major_update_field = kwargs.pop('hide_major_update_field', False)\n\n        super(FeaturedResourceForm, self).__init__(*args, **kwargs)\n        self.helper = FormHelper()\n        self.helper.form_class = 'content-wrapper'\n        self.helper.form_method = 'post'\n        self.helper.form_action = reverse('featured-resource-create')\n\n        fields = [\n            Field('request'),\n            Field('title'),\n            Field('type'),\n            Field('authors'),\n            Field('image_url'),\n            Field('url')\n        ]\n\n        if not hide_major_update_field:\n            fields.append(Field('major_update'))\n\n        fields.extend([\n            Field('pubdate'),\n            ButtonHolder(\n                StrictButton(_('Enregistrer'), type='submit'),\n            )\n        ])\n\n        self.helper.layout = Layout(*fields)\n\n\nclass FeaturedMessageForm(forms.ModelForm):\n    class Meta:\n        model = FeaturedMessage\n\n        fields = ['hook', 'message', 'url']\n\n        widgets = {\n            'hook': forms.TextInput(\n                attrs={\n                    'placeholder': _('Mot d\\'accroche court (\"Nouveau\u00a0!\")')\n                }\n            ),\n\n            'message': forms.TextInput(\n                attrs={\n                    'placeholder': _('Message \u00e0 afficher')\n                }\n            ),\n\n            'url': forms.URLInput(\n                attrs={\n                    'placeholder': _('Lien vers la description de la ressource')\n                }\n            )\n        }\n\n    def __init__(self, *args, **kwargs):\n        super(FeaturedMessageForm, self).__init__(*args, **kwargs)\n        self.helper = FormHelper()\n        self.helper.form_class = 'content-wrapper'\n        self.helper.form_method = 'post'\n        self.helper.form_action = reverse('featured-message-create')\n\n        self.helper.layout = Layout(\n            Field('hook'),\n            Field('message'),\n            Field('url'),\n            ButtonHolder(\n                StrictButton(_('Enregistrer'), type='submit'),\n            ),\n        )\n", "path": "zds/featured/forms.py"}, {"content": "from datetime import datetime, timedelta\n\nfrom django import template\nfrom django.contrib.humanize.templatetags.humanize import naturaltime\nfrom django.template.defaultfilters import date\nfrom django.utils.timezone import get_default_timezone\nfrom django.utils.translation import ugettext_lazy as _\n\nregister = template.Library()\n\n\"\"\"\nDefine a filter to format date.\n\"\"\"\n\n# Date formatting constants\n\n__DATE_FMT_FUTUR = _('Dans le futur')\n__ABS_DATE_FMT_SMALL = _(r'd/m/y \u00e0 H\\hi')       # Small format\n__ABS_DATE_FMT_NORMAL = _(r'l d F Y \u00e0 H\\hi')    # Normal format\n__ABS_HUMAN_TIME_FMT = _('%d %b %Y, %H:%M:%S')\n\n\ndef date_formatter(value, tooltip, small, ignore_future=False):\n    \"\"\"\n    Format a date to an human readable string.\n\n    :param value: Date to format.\n    :param bool tooltip: if `True`, format date to a tooltip label.\n    :param bool small: if `True`, create a shorter string.\n    :return:\n    \"\"\"\n    if not isinstance(value, datetime):\n        return value\n\n    if getattr(value, 'tzinfo', None):\n        now = datetime.now(get_default_timezone())\n    else:\n        now = datetime.now()\n    now = now - timedelta(microseconds=now.microsecond)\n\n    if value > now and not ignore_future:\n        return __DATE_FMT_FUTUR\n    else:\n        delta = now - value\n        # Natural time for today, absolute date after.\n        # Reverse if in tooltip\n        if (delta.days == 0) != tooltip:\n            return naturaltime(value)\n        else:\n            return date(value, str(__ABS_DATE_FMT_SMALL if small else __ABS_DATE_FMT_NORMAL))\n\n\n@register.filter\ndef format_date(value, small=False):\n    \"\"\"\n    Format a date to an human readable string.\n    If ``value`` is in future it is replaced by \"In the future\".\n    \"\"\"\n    return date_formatter(value, tooltip=False, small=small)\n\n\n@register.filter\ndef format_date_no_future(value):\n    \"\"\"\n    Format a date to an human readable string.\n    If ``value`` is in future it is formatted as a normal date.\n    \"\"\"\n    return date_formatter(value, tooltip=False, small=True, ignore_future=True)\n\n\n@register.filter\ndef tooltip_date(value):\n    \"\"\"Format a date to an human readable string. To be used in tooltip.\"\"\"\n    return date_formatter(value, tooltip=True, small=False)\n\n\n@register.filter\ndef humane_time(timestamp):\n    \"\"\"Render time (number of second from epoch) to an human readable string\"\"\"\n    return format_date(datetime.fromtimestamp(timestamp))\n\n\n@register.filter\ndef from_elasticsearch_date(value):\n    try:\n        date = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S.%f')\n    except ValueError:\n        date = datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')\n    return date\n", "path": "zds/utils/templatetags/date.py"}]}