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
a0fd7f1b
Commit
a0fd7f1b
authored
Sep 24, 2018
by
Tim Hoffmann
Committed by
Petr Viktorin
Sep 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate datetime.date.fromtimestamp to Argument Clinic (GH-8535)
parent
9718b59e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
18 deletions
+35
-18
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS.d/next/Documentation/2018-07-28-17-17-42.bpo-20177.cOZJWp.rst
...xt/Documentation/2018-07-28-17-17-42.bpo-20177.cOZJWp.rst
+1
-0
Modules/_datetimemodule.c
Modules/_datetimemodule.c
+20
-17
Modules/clinic/_datetimemodule.c.h
Modules/clinic/_datetimemodule.c.h
+13
-1
No files found.
Misc/ACKS
View file @
a0fd7f1b
...
...
@@ -672,6 +672,7 @@ Benjamin Hodgson
Joerg-Cyril Hoehle
Gregor Hoffleit
Chris Hoffman
Tim Hoffmann
Stefan Hoffmeister
Albert Hofkamp
Chris Hogan
...
...
Misc/NEWS.d/next/Documentation/2018-07-28-17-17-42.bpo-20177.cOZJWp.rst
0 → 100644
View file @
a0fd7f1b
Migrate datetime.date.fromtimestamp to Argument Clinic. Patch by Tim Hoffmann.
Modules/_datetimemodule.c
View file @
a0fd7f1b
...
...
@@ -23,8 +23,9 @@
/*[clinic input]
module datetime
class datetime.datetime "PyDateTime_DateTime *" "&PyDateTime_DateTimeType"
class datetime.date "PyDateTime_Date *" "&PyDateTime_DateType"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=
78142cb64b9e98bc
]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=
25138ad6a696b785
]*/
#include "clinic/_datetimemodule.c.h"
...
...
@@ -2788,9 +2789,8 @@ date_new(PyTypeObject *type, PyObject *args, PyObject *kw)
return
self
;
}
/* Return new date from localtime(t). */
static
PyObject
*
date_
local_from_object
(
PyObject
*
cls
,
PyObject
*
obj
)
date_
fromtimestamp
(
PyObject
*
cls
,
PyObject
*
obj
)
{
struct
tm
tm
;
time_t
t
;
...
...
@@ -2835,19 +2835,26 @@ date_today(PyObject *cls, PyObject *dummy)
return
result
;
}
/* Return new date from given timestamp (Python timestamp -- a double). */
/*[clinic input]
@classmethod
datetime.date.fromtimestamp
timestamp: object
/
Create a date from a POSIX timestamp.
The timestamp is a number, e.g. created via time.time(), that is interpreted
as local time.
[clinic start generated code]*/
static
PyObject
*
date_fromtimestamp
(
PyObject
*
cls
,
PyObject
*
args
)
datetime_date_fromtimestamp
(
PyTypeObject
*
type
,
PyObject
*
timestamp
)
/*[clinic end generated code: output=fd045fda58168869 input=eabb3fe7f40491fe]*/
{
PyObject
*
timestamp
;
PyObject
*
result
=
NULL
;
if
(
PyArg_ParseTuple
(
args
,
"O:fromtimestamp"
,
&
timestamp
))
result
=
date_local_from_object
(
cls
,
timestamp
);
return
result
;
return
date_fromtimestamp
((
PyObject
*
)
type
,
timestamp
);
}
/* Return new date from proleptic Gregorian ordinal. Raises ValueError if
* the ordinal is out of range.
*/
...
...
@@ -3193,11 +3200,7 @@ date_reduce(PyDateTime_Date *self, PyObject *arg)
static
PyMethodDef
date_methods
[]
=
{
/* Class methods: */
{
"fromtimestamp"
,
(
PyCFunction
)
date_fromtimestamp
,
METH_VARARGS
|
METH_CLASS
,
PyDoc_STR
(
"timestamp -> local date from a POSIX timestamp (like "
"time.time())."
)},
DATETIME_DATE_FROMTIMESTAMP_METHODDEF
{
"fromordinal"
,
(
PyCFunction
)
date_fromordinal
,
METH_VARARGS
|
METH_CLASS
,
...
...
Modules/clinic/_datetimemodule.c.h
View file @
a0fd7f1b
...
...
@@ -2,6 +2,18 @@
preserve
[clinic start generated code]*/
PyDoc_STRVAR
(
datetime_date_fromtimestamp__doc__
,
"fromtimestamp($type, timestamp, /)
\n
"
"--
\n
"
"
\n
"
"Create a date from a POSIX timestamp.
\n
"
"
\n
"
"The timestamp is a number, e.g. created via time.time(), that is interpreted
\n
"
"as local time."
);
#define DATETIME_DATE_FROMTIMESTAMP_METHODDEF \
{"fromtimestamp", (PyCFunction)datetime_date_fromtimestamp, METH_O|METH_CLASS, datetime_date_fromtimestamp__doc__},
PyDoc_STRVAR
(
datetime_datetime_now__doc__
,
"now($type, /, tz=None)
\n
"
"--
\n
"
...
...
@@ -36,4 +48,4 @@ datetime_datetime_now(PyTypeObject *type, PyObject *const *args, Py_ssize_t narg
exit:
return
return_value
;
}
/*[clinic end generated code: output=
1fc05897ab239b3f
input=a9049054013a1b77]*/
/*[clinic end generated code: output=
7fd14bd67749da23
input=a9049054013a1b77]*/
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