LCOV - code coverage report
Current view: top level - Modules/clinic - _datetimemodule.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit acb105a7c1f] Lines: 14 32 43.8 %
Date: 2022-07-20 13:12:14 Functions: 1 2 50.0 %
Branches: 12 36 33.3 %

           Branch data     Line data    Source code
       1                 :            : /*[clinic input]
       2                 :            : preserve
       3                 :            : [clinic start generated code]*/
       4                 :            : 
       5                 :            : PyDoc_STRVAR(datetime_date_fromtimestamp__doc__,
       6                 :            : "fromtimestamp($type, timestamp, /)\n"
       7                 :            : "--\n"
       8                 :            : "\n"
       9                 :            : "Create a date from a POSIX timestamp.\n"
      10                 :            : "\n"
      11                 :            : "The timestamp is a number, e.g. created via time.time(), that is interpreted\n"
      12                 :            : "as local time.");
      13                 :            : 
      14                 :            : #define DATETIME_DATE_FROMTIMESTAMP_METHODDEF    \
      15                 :            :     {"fromtimestamp", (PyCFunction)datetime_date_fromtimestamp, METH_O|METH_CLASS, datetime_date_fromtimestamp__doc__},
      16                 :            : 
      17                 :            : static PyObject *
      18                 :            : iso_calendar_date_new_impl(PyTypeObject *type, int year, int week,
      19                 :            :                            int weekday);
      20                 :            : 
      21                 :            : static PyObject *
      22                 :          0 : iso_calendar_date_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
      23                 :            : {
      24                 :          0 :     PyObject *return_value = NULL;
      25                 :            :     static const char * const _keywords[] = {"year", "week", "weekday", NULL};
      26                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "IsoCalendarDate", 0};
      27                 :            :     PyObject *argsbuf[3];
      28                 :            :     PyObject * const *fastargs;
      29                 :          0 :     Py_ssize_t nargs = PyTuple_GET_SIZE(args);
      30                 :            :     int year;
      31                 :            :     int week;
      32                 :            :     int weekday;
      33                 :            : 
      34   [ #  #  #  #  :          0 :     fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 3, 3, 0, argsbuf);
             #  #  #  # ]
      35         [ #  # ]:          0 :     if (!fastargs) {
      36                 :          0 :         goto exit;
      37                 :            :     }
      38                 :          0 :     year = _PyLong_AsInt(fastargs[0]);
      39   [ #  #  #  # ]:          0 :     if (year == -1 && PyErr_Occurred()) {
      40                 :          0 :         goto exit;
      41                 :            :     }
      42                 :          0 :     week = _PyLong_AsInt(fastargs[1]);
      43   [ #  #  #  # ]:          0 :     if (week == -1 && PyErr_Occurred()) {
      44                 :          0 :         goto exit;
      45                 :            :     }
      46                 :          0 :     weekday = _PyLong_AsInt(fastargs[2]);
      47   [ #  #  #  # ]:          0 :     if (weekday == -1 && PyErr_Occurred()) {
      48                 :          0 :         goto exit;
      49                 :            :     }
      50                 :          0 :     return_value = iso_calendar_date_new_impl(type, year, week, weekday);
      51                 :            : 
      52                 :          0 : exit:
      53                 :          0 :     return return_value;
      54                 :            : }
      55                 :            : 
      56                 :            : PyDoc_STRVAR(datetime_datetime_now__doc__,
      57                 :            : "now($type, /, tz=None)\n"
      58                 :            : "--\n"
      59                 :            : "\n"
      60                 :            : "Returns new datetime object representing current time local to tz.\n"
      61                 :            : "\n"
      62                 :            : "  tz\n"
      63                 :            : "    Timezone object.\n"
      64                 :            : "\n"
      65                 :            : "If no tz is specified, uses local timezone.");
      66                 :            : 
      67                 :            : #define DATETIME_DATETIME_NOW_METHODDEF    \
      68                 :            :     {"now", _PyCFunction_CAST(datetime_datetime_now), METH_FASTCALL|METH_KEYWORDS|METH_CLASS, datetime_datetime_now__doc__},
      69                 :            : 
      70                 :            : static PyObject *
      71                 :            : datetime_datetime_now_impl(PyTypeObject *type, PyObject *tz);
      72                 :            : 
      73                 :            : static PyObject *
      74                 :         50 : datetime_datetime_now(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
      75                 :            : {
      76                 :         50 :     PyObject *return_value = NULL;
      77                 :            :     static const char * const _keywords[] = {"tz", NULL};
      78                 :            :     static _PyArg_Parser _parser = {NULL, _keywords, "now", 0};
      79                 :            :     PyObject *argsbuf[1];
      80         [ +  + ]:         50 :     Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
      81                 :         50 :     PyObject *tz = Py_None;
      82                 :            : 
      83   [ +  +  +  -  :         50 :     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
             +  +  -  + ]
      84         [ +  + ]:         50 :     if (!args) {
      85                 :          3 :         goto exit;
      86                 :            :     }
      87         [ +  + ]:         47 :     if (!noptargs) {
      88                 :         31 :         goto skip_optional_pos;
      89                 :            :     }
      90                 :         16 :     tz = args[0];
      91                 :         47 : skip_optional_pos:
      92                 :         47 :     return_value = datetime_datetime_now_impl(type, tz);
      93                 :            : 
      94                 :         50 : exit:
      95                 :         50 :     return return_value;
      96                 :            : }
      97                 :            : /*[clinic end generated code: output=1a3da7479e443e17 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14