Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e16e01fa
Commit
e16e01fa
authored
Nov 27, 2002
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #639112: fixes for None locale and tz.
parent
e4827eb2
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
154 additions
and
61 deletions
+154
-61
Lib/_strptime.py
Lib/_strptime.py
+13
-5
Lib/test/test_strptime.py
Lib/test/test_strptime.py
+141
-56
No files found.
Lib/_strptime.py
View file @
e16e01fa
...
@@ -26,7 +26,6 @@ from re import compile as re_compile
...
@@ -26,7 +26,6 @@ from re import compile as re_compile
from
re
import
IGNORECASE
from
re
import
IGNORECASE
from
string
import
whitespace
as
whitespace_string
from
string
import
whitespace
as
whitespace_string
__version__
=
(
2
,
1
,
6
)
__author__
=
"Brett Cannon"
__author__
=
"Brett Cannon"
__email__
=
"drifty@bigfoot.com"
__email__
=
"drifty@bigfoot.com"
...
@@ -287,13 +286,19 @@ class LocaleTime(object):
...
@@ -287,13 +286,19 @@ class LocaleTime(object):
self
.
__timezone
=
self
.
__pad
(
time
.
tzname
,
0
)
self
.
__timezone
=
self
.
__pad
(
time
.
tzname
,
0
)
def
__calc_lang
(
self
):
def
__calc_lang
(
self
):
# Set self.lang by using locale.getlocale() or
# Set self.__lang by using locale.getlocale() or
# locale.getdefaultlocale().
# locale.getdefaultlocale(). If both turn up empty, set the attribute
# to ''. This is to stop calls to this method and to make sure
# strptime() can produce an re object correctly.
current_lang
=
locale
.
getlocale
(
locale
.
LC_TIME
)[
0
]
current_lang
=
locale
.
getlocale
(
locale
.
LC_TIME
)[
0
]
if
current_lang
:
if
current_lang
:
self
.
__lang
=
current_lang
self
.
__lang
=
current_lang
else
:
else
:
self
.
__lang
=
locale
.
getdefaultlocale
()[
0
]
current_lang
=
locale
.
getdefaultlocale
()[
0
]
if
current_lang
:
self
.
__lang
=
current_lang
else
:
self
.
__lang
=
''
class
TimeRE
(
dict
):
class
TimeRE
(
dict
):
...
@@ -463,7 +468,10 @@ def strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
...
@@ -463,7 +468,10 @@ def strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
julian
=
int
(
found_dict
[
'j'
])
julian
=
int
(
found_dict
[
'j'
])
elif
group_key
==
'Z'
:
elif
group_key
==
'Z'
:
found_zone
=
found_dict
[
'Z'
].
lower
()
found_zone
=
found_dict
[
'Z'
].
lower
()
if
locale_time
.
timezone
[
0
].
lower
()
==
found_zone
:
if
locale_time
.
timezone
[
0
]
==
locale_time
.
timezone
[
1
]:
pass
#Deals with bad locale setup where timezone info is
# the same; first found on FreeBSD 4.4 -current
elif
locale_time
.
timezone
[
0
].
lower
()
==
found_zone
:
tz
=
0
tz
=
0
elif
locale_time
.
timezone
[
1
].
lower
()
==
found_zone
:
elif
locale_time
.
timezone
[
1
].
lower
()
==
found_zone
:
tz
=
1
tz
=
1
...
...
Lib/test/test_strptime.py
View file @
e16e01fa
This diff is collapsed.
Click to expand it.
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