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
7d800bf5
Commit
7d800bf5
authored
Sep 13, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added time.strftime()
parent
c46f18e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
Modules/timemodule.c
Modules/timemodule.c
+50
-0
No files found.
Modules/timemodule.c
View file @
7d800bf5
...
...
@@ -179,6 +179,53 @@ gettmarg(args, p)
return
1
;
}
#ifdef HAVE_STRFTIME
static
object
*
time_strftime
(
self
,
args
)
object
*
self
;
object
*
args
;
{
struct
tm
buf
;
const
char
*
fmt
;
char
*
outbuf
=
0
;
int
i
;
if
(
!
PyArg_ParseTuple
(
args
,
"s(iiiiiiiii)"
,
&
fmt
,
&
(
buf
.
tm_year
),
&
(
buf
.
tm_mon
),
&
(
buf
.
tm_mday
),
&
(
buf
.
tm_hour
),
&
(
buf
.
tm_min
),
&
(
buf
.
tm_sec
),
&
(
buf
.
tm_wday
),
&
(
buf
.
tm_yday
),
&
(
buf
.
tm_isdst
)))
return
NULL
;
if
(
buf
.
tm_year
>=
1900
)
buf
.
tm_year
-=
1900
;
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... */
for
(
i
=
1024
;
i
<
8192
;
i
+=
1024
)
{
outbuf
=
malloc
(
i
);
if
(
outbuf
==
NULL
)
{
return
err_nomem
();
}
if
(
strftime
(
outbuf
,
i
-
1
,
fmt
,
&
buf
)
!=
0
)
{
object
*
ret
;
ret
=
newstringobject
(
outbuf
);
free
(
outbuf
);
return
ret
;
}
free
(
outbuf
);
}
return
err_nomem
();
}
#endif
/* HAVE_STRFTIME */
static
object
*
time_asctime
(
self
,
args
)
object
*
self
;
...
...
@@ -233,6 +280,9 @@ static struct methodlist time_methods[] = {
{
"asctime"
,
time_asctime
},
{
"ctime"
,
time_ctime
},
{
"mktime"
,
time_mktime
},
#ifdef HAVE_STRFTIME
{
"strftime"
,
time_strftime
},
#endif
{
NULL
,
NULL
}
/* sentinel */
};
...
...
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