Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
27ca5ce1
Kaydet (Commit)
27ca5ce1
authored
Ara 20, 2017
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Mar 20, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Used datetime.timezone.utc instead of pytz.utc for better performance.
üst
281c0223
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
20 deletions
+10
-20
file.py
django/contrib/sessions/backends/file.py
+1
-4
storage.py
django/core/files/storage.py
+1
-5
serializer.py
django/db/migrations/serializer.py
+1
-1
feedgenerator.py
django/utils/feedgenerator.py
+1
-2
timezone.py
django/utils/timezone.py
+6
-8
No files found.
django/contrib/sessions/backends/file.py
Dosyayı görüntüle @
27ca5ce1
...
...
@@ -59,10 +59,7 @@ class SessionStore(SessionBase):
Return the modification time of the file storing the session's content.
"""
modification
=
os
.
stat
(
self
.
_key_to_file
())
.
st_mtime
if
settings
.
USE_TZ
:
modification
=
datetime
.
datetime
.
utcfromtimestamp
(
modification
)
return
modification
.
replace
(
tzinfo
=
timezone
.
utc
)
return
datetime
.
datetime
.
fromtimestamp
(
modification
)
return
datetime
.
datetime
.
fromtimestamp
(
modification
,
timezone
.
utc
if
settings
.
USE_TZ
else
None
)
def
_expiry_date
(
self
,
session_data
):
"""
...
...
django/core/files/storage.py
Dosyayı görüntüle @
27ca5ce1
...
...
@@ -336,11 +336,7 @@ class FileSystemStorage(Storage):
If timezone support is enabled, make an aware datetime object in UTC;
otherwise make a naive one in the local timezone.
"""
if
settings
.
USE_TZ
:
# Safe to use .replace() because UTC doesn't have DST
return
datetime
.
utcfromtimestamp
(
ts
)
.
replace
(
tzinfo
=
timezone
.
utc
)
else
:
return
datetime
.
fromtimestamp
(
ts
)
return
datetime
.
fromtimestamp
(
ts
,
timezone
.
utc
if
settings
.
USE_TZ
else
None
)
def
get_accessed_time
(
self
,
name
):
return
self
.
_datetime_from_timestamp
(
os
.
path
.
getatime
(
self
.
path
(
name
)))
...
...
django/db/migrations/serializer.py
Dosyayı görüntüle @
27ca5ce1
...
...
@@ -50,7 +50,7 @@ class DatetimeSerializer(BaseSerializer):
def
serialize
(
self
):
if
self
.
value
.
tzinfo
is
not
None
and
self
.
value
.
tzinfo
!=
utc
:
self
.
value
=
self
.
value
.
astimezone
(
utc
)
value_repr
=
repr
(
self
.
value
)
.
replace
(
"
<UTC>"
,
"utc"
)
value_repr
=
repr
(
self
.
value
)
.
replace
(
"
datetime.timezone(datetime.timedelta(0), 'UTC')"
,
'utc'
)
if
isinstance
(
self
.
value
,
datetime_safe
.
datetime
):
value_repr
=
"datetime.
%
s"
%
value_repr
imports
=
[
"import datetime"
]
...
...
django/utils/feedgenerator.py
Dosyayı görüntüle @
27ca5ce1
...
...
@@ -173,8 +173,7 @@ class SyndicationFeed:
if
latest_date
is
None
or
item_date
>
latest_date
:
latest_date
=
item_date
# datetime.now(tz=utc) is slower, as documented in django.utils.timezone.now
return
latest_date
or
datetime
.
datetime
.
utcnow
()
.
replace
(
tzinfo
=
utc
)
return
latest_date
or
datetime
.
datetime
.
now
(
utc
)
class
Enclosure
:
...
...
django/utils/timezone.py
Dosyayı görüntüle @
27ca5ce1
...
...
@@ -2,9 +2,10 @@
Timezone-related classes and functions.
"""
import
datetime
import
functools
from
contextlib
import
ContextDecorator
from
datetime
import
datetime
,
timedelta
,
tzinfo
from
datetime
import
timedelta
,
tzinfo
from
threading
import
local
import
pytz
...
...
@@ -52,7 +53,8 @@ class FixedOffset(tzinfo):
# UTC time zone as a tzinfo instance.
utc
=
pytz
.
utc
# (Use utc = datetime.timezone.utc here when PY35 isn't supported.)
utc
=
datetime
.
timezone
(
ZERO
,
'UTC'
)
def
get_fixed_timezone
(
offset
):
...
...
@@ -172,7 +174,7 @@ def template_localtime(value, use_tz=None):
This function is designed for use by the template engine.
"""
should_convert
=
(
isinstance
(
value
,
datetime
)
and
isinstance
(
value
,
datetime
.
datetime
)
and
(
settings
.
USE_TZ
if
use_tz
is
None
else
use_tz
)
and
not
is_naive
(
value
)
and
getattr
(
value
,
'convert_to_local_time'
,
True
)
...
...
@@ -219,11 +221,7 @@ def now():
"""
Return an aware or naive datetime.datetime, depending on settings.USE_TZ.
"""
if
settings
.
USE_TZ
:
# timeit shows that datetime.now(tz=utc) is 24% slower
return
datetime
.
utcnow
()
.
replace
(
tzinfo
=
utc
)
else
:
return
datetime
.
now
()
return
datetime
.
datetime
.
now
(
utc
if
settings
.
USE_TZ
else
None
)
# By design, these four functions don't perform any checks on their arguments.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment