Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
event-sourcing / src / event_sourcing / utils / localtime.py
Size: Mime:
from datetime import datetime, tzinfo
from typing import Optional

from django.utils import timezone


def as_localtime(dt: datetime, tz: Optional[tzinfo] = None) -> datetime:
    """
    Convert a tz aware datetime to localtime.

    Wrapper for the django.utils.timezone function, taking the same arguments.
    """
    return timezone.localtime(dt, timezone=tz)


def now() -> datetime:
    """
    Return the current datetime in the local timezone.
    """
    return as_localtime(timezone.now())