18 lines
331 B
Python
18 lines
331 B
Python
import jdatetime
|
|
from django.utils import timezone
|
|
|
|
def to_jalali(dt):
|
|
if not dt:
|
|
return None
|
|
|
|
dt = timezone.localtime(dt)
|
|
|
|
return jdatetime.datetime.fromgregorian(
|
|
year=dt.year,
|
|
month=dt.month,
|
|
day=dt.day,
|
|
hour=dt.hour,
|
|
minute=dt.minute,
|
|
second=dt.second,
|
|
)
|