DateTime 객체¶
다양한 날짜와 시간 객체가 datetime 모듈에서 제공됩니다. 이 함수를 사용하기 전에, 헤더 파일 datetime.h가 소스에 포함되어야 하고 (Python.h가 포함하지 않음에 유의하십시오), 일반적으로 모듈 초기화 함수의 일부로 PyDateTime_IMPORT 매크로를 호출해야 합니다. 매크로는 C 구조체에 대한 포인터를 다음 매크로에서 사용되는 static 변수 PyDateTimeAPI에 넣습니다.
UTC 싱글톤에 액세스하기 위한 매크로:
-
PyObject*
PyDateTime_TimeZone_UTC¶ UTC를 나타내는 시간대 싱글톤을 반환합니다,
datetime.timezone.utc와 같은 객체입니다.버전 3.7에 추가.
형 검사 매크로:
-
int
PyDate_Check(PyObject *ob)¶ Return true if ob is of type
PyDateTime_DateTypeor a subtype ofPyDateTime_DateType. ob must not beNULL.
-
int
PyDate_CheckExact(PyObject *ob)¶ Return true if ob is of type
PyDateTime_DateType. ob must not beNULL.
-
int
PyDateTime_Check(PyObject *ob)¶ Return true if ob is of type
PyDateTime_DateTimeTypeor a subtype ofPyDateTime_DateTimeType. ob must not beNULL.
-
int
PyDateTime_CheckExact(PyObject *ob)¶ Return true if ob is of type
PyDateTime_DateTimeType. ob must not beNULL.
-
int
PyTime_Check(PyObject *ob)¶ Return true if ob is of type
PyDateTime_TimeTypeor a subtype ofPyDateTime_TimeType. ob must not beNULL.
-
int
PyTime_CheckExact(PyObject *ob)¶ Return true if ob is of type
PyDateTime_TimeType. ob must not beNULL.
-
int
PyDelta_Check(PyObject *ob)¶ Return true if ob is of type
PyDateTime_DeltaTypeor a subtype ofPyDateTime_DeltaType. ob must not beNULL.
-
int
PyDelta_CheckExact(PyObject *ob)¶ Return true if ob is of type
PyDateTime_DeltaType. ob must not beNULL.
-
int
PyTZInfo_Check(PyObject *ob)¶ Return true if ob is of type
PyDateTime_TZInfoTypeor a subtype ofPyDateTime_TZInfoType. ob must not beNULL.
-
int
PyTZInfo_CheckExact(PyObject *ob)¶ Return true if ob is of type
PyDateTime_TZInfoType. ob must not beNULL.
객체를 만드는 매크로:
-
PyObject*
PyDate_FromDate(int year, int month, int day)¶ - Return value: New reference.
지정된 년, 월, 일의
datetime.date객체를 반환합니다.
-
PyObject*
PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond)¶ - Return value: New reference.
지정된 년, 월, 일, 시, 분, 초 및 마이크로초의
datetime.datetime객체를 반환합니다.
-
PyObject*
PyDateTime_FromDateAndTimeAndFold(int year, int month, int day, int hour, int minute, int second, int usecond, int fold)¶ - Return value: New reference.
지정된 년, 월, 일, 시, 분, 초, 마이크로초 및 fold의
datetime.datetime객체를 반환합니다.버전 3.6에 추가.
-
PyObject*
PyTime_FromTime(int hour, int minute, int second, int usecond)¶ - Return value: New reference.
지정된 시, 분, 초 및 마이크로초의
datetime.time객체를 반환합니다.
-
PyObject*
PyTime_FromTimeAndFold(int hour, int minute, int second, int usecond, int fold)¶ - Return value: New reference.
지정된 시, 분, 초, 마이크로초 및 fold의
datetime.time객체를 반환합니다.버전 3.6에 추가.
-
PyObject*
PyDelta_FromDSU(int days, int seconds, int useconds)¶ - Return value: New reference.
지정된 일, 초 및 마이크로초 수를 나타내는
datetime.timedelta객체를 반환합니다. 결과 마이크로초와 초가datetime.timedelta객체에 관해 설명된 범위에 있도록 정규화가 수행됩니다.
-
PyObject*
PyTimeZone_FromOffset(PyDateTime_DeltaType* offset)¶ - Return value: New reference.
offset 인자로 나타내지는 이름이 없는 고정 오프셋의
datetime.timezone객체를 돌려줍니다.버전 3.7에 추가.
-
PyObject*
PyTimeZone_FromOffsetAndName(PyDateTime_DeltaType* offset, PyUnicode* name)¶ - Return value: New reference.
offset 인자와 tzname name으로 나타내지는 고정 오프셋의
datetime.timezone객체를 돌려줍니다.버전 3.7에 추가.
Macros to extract fields from date objects. The argument must be an instance of
PyDateTime_Date, including subclasses (such as
PyDateTime_DateTime). The argument must not be NULL, and the type is
not checked:
-
int
PyDateTime_GET_YEAR(PyDateTime_Date *o)¶ 양의 int로, 년을 반환합니다.
-
int
PyDateTime_GET_MONTH(PyDateTime_Date *o)¶ 1에서 12까지의 int로, 월을 반환합니다.
-
int
PyDateTime_GET_DAY(PyDateTime_Date *o)¶ 1에서 31까지의 int로, 일을 반환합니다.
Macros to extract fields from datetime objects. The argument must be an
instance of PyDateTime_DateTime, including subclasses. The argument
must not be NULL, and the type is not checked:
-
int
PyDateTime_DATE_GET_HOUR(PyDateTime_DateTime *o)¶ 0부터 23까지의 int로, 시를 반환합니다.
-
int
PyDateTime_DATE_GET_MINUTE(PyDateTime_DateTime *o)¶ 0부터 59까지의 int로, 분을 반환합니다.
-
int
PyDateTime_DATE_GET_SECOND(PyDateTime_DateTime *o)¶ 0부터 59까지의 int로, 초를 반환합니다.
-
int
PyDateTime_DATE_GET_MICROSECOND(PyDateTime_DateTime *o)¶ 0부터 999999까지의 int로, 마이크로초를 반환합니다.
-
int
PyDateTime_DATE_GET_FOLD(PyDateTime_DateTime *o)¶ Return the fold, as an int from 0 through 1.
버전 3.6에 추가.
Macros to extract fields from time objects. The argument must be an instance of
PyDateTime_Time, including subclasses. The argument must not be NULL,
and the type is not checked:
-
int
PyDateTime_TIME_GET_HOUR(PyDateTime_Time *o)¶ 0부터 23까지의 int로, 시를 반환합니다.
-
int
PyDateTime_TIME_GET_MINUTE(PyDateTime_Time *o)¶ 0부터 59까지의 int로, 분을 반환합니다.
-
int
PyDateTime_TIME_GET_SECOND(PyDateTime_Time *o)¶ 0부터 59까지의 int로, 초를 반환합니다.
-
int
PyDateTime_TIME_GET_MICROSECOND(PyDateTime_Time *o)¶ 0부터 999999까지의 int로, 마이크로초를 반환합니다.
-
int
PyDateTime_TIME_GET_FOLD(PyDateTime_Time *o)¶ Return the fold, as an int from 0 through 1.
버전 3.6에 추가.
Macros to extract fields from time delta objects. The argument must be an
instance of PyDateTime_Delta, including subclasses. The argument must
not be NULL, and the type is not checked:
-
int
PyDateTime_DELTA_GET_DAYS(PyDateTime_Delta *o)¶ -999999999에서 999999999까지의 int로, 일 수를 반환합니다.
버전 3.3에 추가.
-
int
PyDateTime_DELTA_GET_SECONDS(PyDateTime_Delta *o)¶ 0부터 86399까지의 int로, 초 수를 반환합니다.
버전 3.3에 추가.
-
int
PyDateTime_DELTA_GET_MICROSECONDS(PyDateTime_Delta *o)¶ 0에서 999999까지의 int로, 마이크로초 수를 반환합니다.
버전 3.3에 추가.
DB API를 구현하는 모듈의 편의를 위한 매크로:
-
PyObject*
PyDateTime_FromTimestamp(PyObject *args)¶ - Return value: New reference.
datetime.datetime.fromtimestamp()에 전달하는 데 적합한 인자 튜플로 새datetime.datetime객체를 만들고 반환합니다.
-
PyObject*
PyDate_FromTimestamp(PyObject *args)¶ - Return value: New reference.
datetime.date.fromtimestamp()에 전달하는 데 적합한 인자 튜플로 새datetime.date객체를 만들고 반환합니다.
