Format a time according to the given format.
(value, arg=None)
| 797 | |
| 798 | @register.filter(expects_localtime=True, is_safe=False) |
| 799 | def time(value, arg=None): |
| 800 | """Format a time according to the given format.""" |
| 801 | if value in (None, ""): |
| 802 | return "" |
| 803 | try: |
| 804 | return formats.time_format(value, arg) |
| 805 | except (AttributeError, TypeError): |
| 806 | try: |
| 807 | return time_format(value, arg) |
| 808 | except (AttributeError, TypeError): |
| 809 | return "" |
| 810 | |
| 811 | |
| 812 | @register.filter("timesince", is_safe=False) |