blob: 4d92049581579f01d48939193ed111c1125d29aa [file] [log] [blame]
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(datetime_datetime_now__doc__,
6"now($type, /, tz=None)\n"
7"--\n"
8"\n"
9"Returns new datetime object representing current time local to tz.\n"
10"\n"
11" tz\n"
12" Timezone object.\n"
13"\n"
14"If no tz is specified, uses local timezone.");
15
16#define DATETIME_DATETIME_NOW_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +030017 {"now", (PyCFunction)datetime_datetime_now, METH_FASTCALL|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030018
19static PyObject *
20datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz);
21
22static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +020023datetime_datetime_now(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030024{
25 PyObject *return_value = NULL;
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +030026 static const char * const _keywords[] = {"tz", NULL};
27 static _PyArg_Parser _parser = {"|O:now", _keywords, 0};
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030028 PyObject *tz = Py_None;
29
Victor Stinner3e1fad62017-01-17 01:29:01 +010030 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030031 &tz)) {
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030032 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030033 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030034 return_value = datetime_datetime_now_impl(type, tz);
35
36exit:
37 return return_value;
38}
Serhiy Storchakaa5552f02017-12-15 13:11:11 +020039/*[clinic end generated code: output=1fc05897ab239b3f input=a9049054013a1b77]*/