Repository URL to install this package:
|
Version:
0.1.3 ▾
|
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())