cpython/Include/datetime.h

/*  datetime.h
 */
#ifndef Py_LIMITED_API
#ifndef DATETIME_H
#define DATETIME_H
#ifdef __cplusplus
extern "C" {
#endif

/* Fields are packed into successive bytes, each viewed as unsigned and
 * big-endian, unless otherwise noted:
 *
 * byte offset
 *  0           year     2 bytes, 1-9999
 *  2           month    1 byte, 1-12
 *  3           day      1 byte, 1-31
 *  4           hour     1 byte, 0-23
 *  5           minute   1 byte, 0-59
 *  6           second   1 byte, 0-59
 *  7           usecond  3 bytes, 0-999999
 * 10
 */

/* # of bytes for year, month, and day. */
#define _PyDateTime_DATE_DATASIZE

/* # of bytes for hour, minute, second, and usecond. */
#define _PyDateTime_TIME_DATASIZE

/* # of bytes for year, month, day, hour, minute, second, and usecond. */
#define _PyDateTime_DATETIME_DATASIZE


PyDateTime_Delta;

PyDateTime_TZInfo;


/* The datetime and time types have hashcodes, and an optional tzinfo member,
 * present if and only if hastzinfo is true.
 */
#define _PyTZINFO_HEAD

/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something
 * convenient to cast to, when getting at the hastzinfo member of objects
 * starting with _PyTZINFO_HEAD.
 */
_PyDateTime_BaseTZInfo;

/* All time objects are of PyDateTime_TimeType, but that can be allocated
 * in two ways, with or without a tzinfo member.  Without is the same as
 * tzinfo == None, but consumes less memory.  _PyDateTime_BaseTime is an
 * internal struct used to allocate the right amount of space for the
 * "without" case.
 */
#define _PyDateTime_TIMEHEAD

_PyDateTime_BaseTime;         /* hastzinfo false */

PyDateTime_Time;              /* hastzinfo true */


/* All datetime objects are of PyDateTime_DateTimeType, but that can be
 * allocated in two ways too, just like for time objects above.  In addition,
 * the plain date type is a base class for datetime, so it must also have
 * a hastzinfo member (although it's unused there).
 */
PyDateTime_Date;

#define _PyDateTime_DATETIMEHEAD

_PyDateTime_BaseDateTime;     /* hastzinfo false */

PyDateTime_DateTime;          /* hastzinfo true */


/* Apply for date and datetime instances. */

// o is a pointer to a time or a datetime object.
#define _PyDateTime_HAS_TZINFO(o)

#define PyDateTime_GET_YEAR(o)
#define PyDateTime_GET_MONTH(o)
#define PyDateTime_GET_DAY(o)

#define PyDateTime_DATE_GET_HOUR(o)
#define PyDateTime_DATE_GET_MINUTE(o)
#define PyDateTime_DATE_GET_SECOND(o)
#define PyDateTime_DATE_GET_MICROSECOND(o)
#define PyDateTime_DATE_GET_FOLD(o)
#define PyDateTime_DATE_GET_TZINFO(o)

/* Apply for time instances. */
#define PyDateTime_TIME_GET_HOUR(o)
#define PyDateTime_TIME_GET_MINUTE(o)
#define PyDateTime_TIME_GET_SECOND(o)
#define PyDateTime_TIME_GET_MICROSECOND(o)
#define PyDateTime_TIME_GET_FOLD(o)
#define PyDateTime_TIME_GET_TZINFO(o)

/* Apply for time delta instances */
#define PyDateTime_DELTA_GET_DAYS(o)
#define PyDateTime_DELTA_GET_SECONDS(o)
#define PyDateTime_DELTA_GET_MICROSECONDS(o)


/* Define structure for C API. */
PyDateTime_CAPI;

#define PyDateTime_CAPSULE_NAME


/* This block is only used as part of the public API and should not be
 * included in _datetimemodule.c, which does not use the C API capsule.
 * See bpo-35081 for more details.
 * */
#ifndef _PY_DATETIME_IMPL
/* Define global variable for the C API and a macro for setting it. */
static PyDateTime_CAPI *PyDateTimeAPI =;

#define PyDateTime_IMPORT

/* Macro for access to the UTC singleton */
#define PyDateTime_TimeZone_UTC

/* Macros for type checking when not building the Python core. */
#define PyDate_Check(op)
#define PyDate_CheckExact(op)

#define PyDateTime_Check(op)
#define PyDateTime_CheckExact(op)

#define PyTime_Check(op)
#define PyTime_CheckExact(op)

#define PyDelta_Check(op)
#define PyDelta_CheckExact(op)

#define PyTZInfo_Check(op)
#define PyTZInfo_CheckExact(op)


/* Macros for accessing constructors in a simplified fashion. */
#define PyDate_FromDate(year, month, day)

#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec)

#define PyDateTime_FromDateAndTimeAndFold(year, month, day, hour, min, sec, usec, fold)

#define PyTime_FromTime(hour, minute, second, usecond)

#define PyTime_FromTimeAndFold(hour, minute, second, usecond, fold)

#define PyDelta_FromDSU(days, seconds, useconds)

#define PyTimeZone_FromOffset(offset)

#define PyTimeZone_FromOffsetAndName(offset, name)

/* Macros supporting the DB API. */
#define PyDateTime_FromTimestamp(args)

#define PyDate_FromTimestamp(args)

#endif   /* !defined(_PY_DATETIME_IMPL) */

#ifdef __cplusplus
}
#endif
#endif
#endif /* !Py_LIMITED_API */