from datetime import datetime

from django import template
from django.template.defaultfilters import stringfilter
from pytz import UTC

register = template.Library()


@register.filter
@stringfilter
def decorate(value, _arg=None):
    """
    Template filter to decorate the value with hyphens.

    Args:
        value: Any value that can be displayed and filtered.
        _arg: Option passed for the filter, if any

    Returns:
        Decorated value, like --<value>--

    """
    return f"--{value}--"


@register.simple_tag
def current_time():
    """
    Template tag that returns the current time, with the UTC timezone.

    Returns:
        Now in UTC.

    """
    return datetime.now(tz=UTC)
