CoolFace
Apppublic

vidya7732/AI_Doctor_LLM_GenModel

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
datetime.h260 linesDownload Raw Back to include
1/*  datetime.h2 */3#ifndef Py_LIMITED_API4#ifndef DATETIME_H5#define DATETIME_H6#ifdef __cplusplus7extern "C" {8#endif9 10/* Fields are packed into successive bytes, each viewed as unsigned and11 * big-endian, unless otherwise noted:12 *13 * byte offset14 *  0           year     2 bytes, 1-999915 *  2           month    1 byte, 1-1216 *  3           day      1 byte, 1-3117 *  4           hour     1 byte, 0-2318 *  5           minute   1 byte, 0-5919 *  6           second   1 byte, 0-5920 *  7           usecond  3 bytes, 0-99999921 * 1022 */23 24/* # of bytes for year, month, and day. */25#define _PyDateTime_DATE_DATASIZE 426 27/* # of bytes for hour, minute, second, and usecond. */28#define _PyDateTime_TIME_DATASIZE 629 30/* # of bytes for year, month, day, hour, minute, second, and usecond. */31#define _PyDateTime_DATETIME_DATASIZE 1032 33 34typedef struct35{36    PyObject_HEAD37    Py_hash_t hashcode;         /* -1 when unknown */38    int days;                   /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */39    int seconds;                /* 0 <= seconds < 24*3600 is invariant */40    int microseconds;           /* 0 <= microseconds < 1000000 is invariant */41} PyDateTime_Delta;42 43typedef struct44{45    PyObject_HEAD               /* a pure abstract base class */46} PyDateTime_TZInfo;47 48 49/* The datetime and time types have hashcodes, and an optional tzinfo member,50 * present if and only if hastzinfo is true.51 */52#define _PyTZINFO_HEAD          \53    PyObject_HEAD               \54    Py_hash_t hashcode;         \55    char hastzinfo;             /* boolean flag */56 57/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something58 * convenient to cast to, when getting at the hastzinfo member of objects59 * starting with _PyTZINFO_HEAD.60 */61typedef struct62{63    _PyTZINFO_HEAD64} _PyDateTime_BaseTZInfo;65 66/* All time objects are of PyDateTime_TimeType, but that can be allocated67 * in two ways, with or without a tzinfo member.  Without is the same as68 * tzinfo == None, but consumes less memory.  _PyDateTime_BaseTime is an69 * internal struct used to allocate the right amount of space for the70 * "without" case.71 */72#define _PyDateTime_TIMEHEAD    \73    _PyTZINFO_HEAD              \74    unsigned char data[_PyDateTime_TIME_DATASIZE];75 76typedef struct77{78    _PyDateTime_TIMEHEAD79} _PyDateTime_BaseTime;         /* hastzinfo false */80 81typedef struct82{83    _PyDateTime_TIMEHEAD84    unsigned char fold;85    PyObject *tzinfo;86} PyDateTime_Time;              /* hastzinfo true */87 88 89/* All datetime objects are of PyDateTime_DateTimeType, but that can be90 * allocated in two ways too, just like for time objects above.  In addition,91 * the plain date type is a base class for datetime, so it must also have92 * a hastzinfo member (although it's unused there).93 */94typedef struct95{96    _PyTZINFO_HEAD97    unsigned char data[_PyDateTime_DATE_DATASIZE];98} PyDateTime_Date;99 100#define _PyDateTime_DATETIMEHEAD        \101    _PyTZINFO_HEAD                      \102    unsigned char data[_PyDateTime_DATETIME_DATASIZE];103 104typedef struct105{106    _PyDateTime_DATETIMEHEAD107} _PyDateTime_BaseDateTime;     /* hastzinfo false */108 109typedef struct110{111    _PyDateTime_DATETIMEHEAD112    unsigned char fold;113    PyObject *tzinfo;114} PyDateTime_DateTime;          /* hastzinfo true */115 116 117/* Apply for date and datetime instances. */118#define PyDateTime_GET_YEAR(o)     ((((PyDateTime_Date*)o)->data[0] << 8) | \119                     ((PyDateTime_Date*)o)->data[1])120#define PyDateTime_GET_MONTH(o)    (((PyDateTime_Date*)o)->data[2])121#define PyDateTime_GET_DAY(o)      (((PyDateTime_Date*)o)->data[3])122 123#define PyDateTime_DATE_GET_HOUR(o)        (((PyDateTime_DateTime*)o)->data[4])124#define PyDateTime_DATE_GET_MINUTE(o)      (((PyDateTime_DateTime*)o)->data[5])125#define PyDateTime_DATE_GET_SECOND(o)      (((PyDateTime_DateTime*)o)->data[6])126#define PyDateTime_DATE_GET_MICROSECOND(o)              \127    ((((PyDateTime_DateTime*)o)->data[7] << 16) |       \128     (((PyDateTime_DateTime*)o)->data[8] << 8)  |       \129      ((PyDateTime_DateTime*)o)->data[9])130#define PyDateTime_DATE_GET_FOLD(o)        (((PyDateTime_DateTime*)o)->fold)131 132/* Apply for time instances. */133#define PyDateTime_TIME_GET_HOUR(o)        (((PyDateTime_Time*)o)->data[0])134#define PyDateTime_TIME_GET_MINUTE(o)      (((PyDateTime_Time*)o)->data[1])135#define PyDateTime_TIME_GET_SECOND(o)      (((PyDateTime_Time*)o)->data[2])136#define PyDateTime_TIME_GET_MICROSECOND(o)              \137    ((((PyDateTime_Time*)o)->data[3] << 16) |           \138     (((PyDateTime_Time*)o)->data[4] << 8)  |           \139      ((PyDateTime_Time*)o)->data[5])140#define PyDateTime_TIME_GET_FOLD(o)        (((PyDateTime_Time*)o)->fold)141 142/* Apply for time delta instances */143#define PyDateTime_DELTA_GET_DAYS(o)         (((PyDateTime_Delta*)o)->days)144#define PyDateTime_DELTA_GET_SECONDS(o)      (((PyDateTime_Delta*)o)->seconds)145#define PyDateTime_DELTA_GET_MICROSECONDS(o)            \146    (((PyDateTime_Delta*)o)->microseconds)147 148 149/* Define structure for C API. */150typedef struct {151    /* type objects */152    PyTypeObject *DateType;153    PyTypeObject *DateTimeType;154    PyTypeObject *TimeType;155    PyTypeObject *DeltaType;156    PyTypeObject *TZInfoType;157 158    /* singletons */159    PyObject *TimeZone_UTC;160 161    /* constructors */162    PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);163    PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,164        PyObject*, PyTypeObject*);165    PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);166    PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);167    PyObject *(*TimeZone_FromTimeZone)(PyObject *offset, PyObject *name);168 169    /* constructors for the DB API */170    PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*);171    PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*);172 173    /* PEP 495 constructors */174    PyObject *(*DateTime_FromDateAndTimeAndFold)(int, int, int, int, int, int, int,175        PyObject*, int, PyTypeObject*);176    PyObject *(*Time_FromTimeAndFold)(int, int, int, int, PyObject*, int, PyTypeObject*);177 178} PyDateTime_CAPI;179 180#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI"181 182 183/* This block is only used as part of the public API and should not be184 * included in _datetimemodule.c, which does not use the C API capsule.185 * See bpo-35081 for more details.186 * */187#ifndef _PY_DATETIME_IMPL188/* Define global variable for the C API and a macro for setting it. */189static PyDateTime_CAPI *PyDateTimeAPI = NULL;190 191#define PyDateTime_IMPORT \192    PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)193 194/* Macro for access to the UTC singleton */195#define PyDateTime_TimeZone_UTC PyDateTimeAPI->TimeZone_UTC196 197/* Macros for type checking when not building the Python core. */198#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)199#define PyDate_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->DateType)200 201#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)202#define PyDateTime_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->DateTimeType)203 204#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)205#define PyTime_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->TimeType)206 207#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)208#define PyDelta_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->DeltaType)209 210#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)211#define PyTZInfo_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->TZInfoType)212 213 214/* Macros for accessing constructors in a simplified fashion. */215#define PyDate_FromDate(year, month, day) \216    PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType)217 218#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \219    PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \220        min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType)221 222#define PyDateTime_FromDateAndTimeAndFold(year, month, day, hour, min, sec, usec, fold) \223    PyDateTimeAPI->DateTime_FromDateAndTimeAndFold(year, month, day, hour, \224        min, sec, usec, Py_None, fold, PyDateTimeAPI->DateTimeType)225 226#define PyTime_FromTime(hour, minute, second, usecond) \227    PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \228        Py_None, PyDateTimeAPI->TimeType)229 230#define PyTime_FromTimeAndFold(hour, minute, second, usecond, fold) \231    PyDateTimeAPI->Time_FromTimeAndFold(hour, minute, second, usecond, \232        Py_None, fold, PyDateTimeAPI->TimeType)233 234#define PyDelta_FromDSU(days, seconds, useconds) \235    PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \236        PyDateTimeAPI->DeltaType)237 238#define PyTimeZone_FromOffset(offset) \239    PyDateTimeAPI->TimeZone_FromTimeZone(offset, NULL)240 241#define PyTimeZone_FromOffsetAndName(offset, name) \242    PyDateTimeAPI->TimeZone_FromTimeZone(offset, name)243 244/* Macros supporting the DB API. */245#define PyDateTime_FromTimestamp(args) \246    PyDateTimeAPI->DateTime_FromTimestamp( \247        (PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL)248 249#define PyDate_FromTimestamp(args) \250    PyDateTimeAPI->Date_FromTimestamp( \251        (PyObject*) (PyDateTimeAPI->DateType), args)252 253#endif   /* !defined(_PY_DATETIME_IMPL) */254 255#ifdef __cplusplus256}257#endif258#endif259#endif /* !Py_LIMITED_API */260