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
b70c822b
Commit
b70c822b
authored
Jan 13, 1997
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting, and minor error detection
parent
7249c6cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
49 deletions
+52
-49
Modules/timemodule.c
Modules/timemodule.c
+52
-49
No files found.
Modules/timemodule.c
View file @
b70c822b
...
...
@@ -129,12 +129,12 @@ time_sleep(self, args)
if
(
!
PyArg_Parse
(
args
,
"d"
,
&
secs
))
return
NULL
;
Py_BEGIN_ALLOW_THREADS
if
(
floatsleep
(
secs
)
!=
0
)
{
Py_BLOCK_THREADS
return
NULL
;
}
if
(
floatsleep
(
secs
)
!=
0
)
{
Py_BLOCK_THREADS
return
NULL
;
}
Py_END_ALLOW_THREADS
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
...
...
@@ -154,15 +154,15 @@ time_convert(when, function)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
}
return
Py_BuildValue
(
"(iiiiiiiii)"
,
p
->
tm_year
+
1900
,
p
->
tm_mon
+
1
,
/* Want January == 1 */
p
->
tm_mday
,
p
->
tm_hour
,
p
->
tm_min
,
p
->
tm_sec
,
(
p
->
tm_wday
+
6
)
%
7
,
/* Want Monday == 0 */
p
->
tm_yday
+
1
,
/* Want January, 1 == 1 */
p
->
tm_isdst
);
p
->
tm_year
+
1900
,
p
->
tm_mon
+
1
,
/* Want January == 1 */
p
->
tm_mday
,
p
->
tm_hour
,
p
->
tm_min
,
p
->
tm_sec
,
(
p
->
tm_wday
+
6
)
%
7
,
/* Want Monday == 0 */
p
->
tm_yday
+
1
,
/* Want January, 1 == 1 */
p
->
tm_isdst
);
}
static
PyObject
*
...
...
@@ -193,15 +193,15 @@ gettmarg(args, p)
struct
tm
*
p
;
{
if
(
!
PyArg_Parse
(
args
,
"(iiiiiiiii)"
,
&
p
->
tm_year
,
&
p
->
tm_mon
,
&
p
->
tm_mday
,
&
p
->
tm_hour
,
&
p
->
tm_min
,
&
p
->
tm_sec
,
&
p
->
tm_wday
,
&
p
->
tm_yday
,
&
p
->
tm_isdst
))
&
p
->
tm_year
,
&
p
->
tm_mon
,
&
p
->
tm_mday
,
&
p
->
tm_hour
,
&
p
->
tm_min
,
&
p
->
tm_sec
,
&
p
->
tm_wday
,
&
p
->
tm_yday
,
&
p
->
tm_isdst
))
return
0
;
if
(
p
->
tm_year
>=
1900
)
p
->
tm_year
-=
1900
;
...
...
@@ -239,8 +239,9 @@ time_strftime(self, args)
buf
.
tm_mon
--
;
buf
.
tm_wday
=
(
buf
.
tm_wday
+
1
)
%
7
;
buf
.
tm_yday
--
;
/* I hate these functions that presume you know how big the output */
/* will be ahead of time... */
/* I hate these functions that presume you know how big the output
* will be ahead of time...
*/
for
(
i
=
1024
;
i
<
8192
;
i
+=
1024
)
{
outbuf
=
malloc
(
i
);
if
(
outbuf
==
NULL
)
{
...
...
@@ -366,7 +367,7 @@ inittime()
long
winterzone
,
summerzone
;
char
wintername
[
10
],
summername
[
10
];
/* XXX This won't work on the southern hemisphere.
XXX Anybody got a better idea? */
XXX Anybody got a better idea? */
t
=
(
time
((
time_t
*
)
0
)
/
YEAR
)
*
YEAR
;
p
=
localtime
(
&
t
);
winterzone
=
-
p
->
tm_gmtoff
;
...
...
@@ -386,6 +387,8 @@ inittime()
}
#endif
/* HAVE_TM_ZONE */
#endif
/* !HAVE_TZNAME */
if
(
PyErr_Occurred
())
Py_FatalError
(
"Can't initialize time module"
);
}
...
...
@@ -395,36 +398,36 @@ static double
floattime
()
{
/* There are three ways to get the time:
(1) gettimeofday() -- resolution in microseconds
(2) ftime() -- resolution in milliseconds
(3) time() -- resolution in seconds
In all cases the return value is a float in seconds.
Since on some systems (e.g. SCO ODT 3.0) gettimeofday() may
fail, so we fall back on ftime() or time().
Note: clock resolution does not imply clock accuracy! */
(1) gettimeofday() -- resolution in microseconds
(2) ftime() -- resolution in milliseconds
(3) time() -- resolution in seconds
In all cases the return value is a float in seconds.
Since on some systems (e.g. SCO ODT 3.0) gettimeofday() may
fail, so we fall back on ftime() or time().
Note: clock resolution does not imply clock accuracy! */
#ifdef HAVE_GETTIMEOFDAY
{
struct
timeval
t
;
{
struct
timeval
t
;
#ifdef GETTIMEOFDAY_NO_TZ
if
(
gettimeofday
(
&
t
)
==
0
)
return
(
double
)
t
.
tv_sec
+
t
.
tv_usec
*
0
.
000001
;
if
(
gettimeofday
(
&
t
)
==
0
)
return
(
double
)
t
.
tv_sec
+
t
.
tv_usec
*
0
.
000001
;
#else
/* !GETTIMEOFDAY_NO_TZ */
if
(
gettimeofday
(
&
t
,
(
struct
timezone
*
)
NULL
)
==
0
)
return
(
double
)
t
.
tv_sec
+
t
.
tv_usec
*
0
.
000001
;
if
(
gettimeofday
(
&
t
,
(
struct
timezone
*
)
NULL
)
==
0
)
return
(
double
)
t
.
tv_sec
+
t
.
tv_usec
*
0
.
000001
;
#endif
/* !GETTIMEOFDAY_NO_TZ */
}
}
#endif
/* !HAVE_GETTIMEOFDAY */
{
{
#ifdef HAVE_FTIME
struct
timeb
t
;
ftime
(
&
t
);
return
(
double
)
t
.
time
+
(
double
)
t
.
millitm
*
(
double
)
0
.
001
;
struct
timeb
t
;
ftime
(
&
t
);
return
(
double
)
t
.
time
+
(
double
)
t
.
millitm
*
(
double
)
0
.
001
;
#else
/* !HAVE_FTIME */
time_t
secs
;
time
(
&
secs
);
return
(
double
)
secs
;
time_t
secs
;
time
(
&
secs
);
return
(
double
)
secs
;
#endif
/* !HAVE_FTIME */
}
}
}
...
...
@@ -436,7 +439,7 @@ static int
#ifdef MPW
floatsleep
(
double
secs
)
#else
floatsleep
(
secs
)
floatsleep
(
secs
)
double
secs
;
#endif
/* MPW */
{
...
...
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