djavedt-1.0.0
توضیحات
Some useful datetime functions for Django
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | djavedt-1.0.0 |
| نام | djavedt |
| نسخه کتابخانه | 1.0.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | David Smith |
| ایمیل نویسنده | dasmith2@example.com |
| آدرس صفحه اصلی | https://github.com/dasmith2/djavedt |
| آدرس اینترنتی | https://pypi.org/project/djavedt/ |
| مجوز | - |
# Introduction
These utility functions are helpful in handling dates, datetimes, and timezones
in Django.
# Examples
Let's say you have the following in your Django settings.py
TIME_ZONE = 'EST'
USE_TZ = True
Now let's attempt to write our own tomorrow() function.
from datetime import timedelta
from django.utils.timezone import now
def tomorrow():
# Subtle bug! Django's now() function returns a timezone enabled datetime
# in UTC, regardless of the TIME_ZONE setting. If it's 11 Wednesday
# MORNING in New York, this function will work. But if it's 11 Wednesday
# NIGHT in New York, the UTC timezone is already in Thursday, so in that
# case this code will return Friday.
return now().date() + timedelta(days=1)
Here's one way to fix the problem.
from datetime import timedelta
from djavedt import now
def tomorrow():
# djavedt's now() function returns a timezone enabled datetime in the
# timezone of the TIME_ZONE setting, which is EST in our example. So this
# function will work as expected at 11PM in New York.
return now().date() + timedelta(days=1)
نیازمندی
| مقدار | نام |
|---|---|
| - | django |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl djavedt-1.0.0:
pip install djavedt-1.0.0.whl
نصب پکیج tar.gz djavedt-1.0.0:
pip install djavedt-1.0.0.tar.gz