DateTime 객체¶
다양한 날짜와 시간 객체가 datetime
모듈에서 제공됩니다. 이 함수를 사용하기 전에, 헤더 파일 datetime.h
가 소스에 포함되어야 하고 (Python.h
가 포함하지 않음에 유의하십시오), 일반적으로 모듈 초기화 함수의 일부로 PyDateTime_IMPORT
매크로를 호출해야 합니다. 매크로는 C 구조체에 대한 포인터를 다음 매크로에서 사용되는 static 변수 PyDateTimeAPI
에 넣습니다.
-
type PyDateTime_Delta¶
This subtype of
PyObject
represents the difference between two datetime values.
-
PyTypeObject PyDateTime_DateType¶
This instance of
PyTypeObject
represents the Python date type; it is the same object asdatetime.date
in the Python layer.
-
PyTypeObject PyDateTime_DateTimeType¶
This instance of
PyTypeObject
represents the Python datetime type; it is the same object asdatetime.datetime
in the Python layer.
-
PyTypeObject PyDateTime_TimeType¶
This instance of
PyTypeObject
represents the Python time type; it is the same object asdatetime.time
in the Python layer.
-
PyTypeObject PyDateTime_DeltaType¶
This instance of
PyTypeObject
represents Python type for the difference between two datetime values; it is the same object asdatetime.timedelta
in the Python layer.
-
PyTypeObject PyDateTime_TZInfoType¶
This instance of
PyTypeObject
represents the Python time zone info type; it is the same object asdatetime.tzinfo
in the Python layer.
UTC 싱글톤에 액세스하기 위한 매크로:
-
PyObject *PyDateTime_TimeZone_UTC¶
UTC를 나타내는 시간대 싱글톤을 반환합니다,
datetime.timezone.utc
와 같은 객체입니다.Added in version 3.7.
형 검사 매크로:
-
int PyDate_Check(PyObject *ob)¶
ob가
PyDateTime_DateType
형이거나PyDateTime_DateType
의 서브 형이면 참을 돌려줍니다. ob는NULL
이 아니어야 합니다. 이 함수는 항상 성공합니다.
-
int PyDate_CheckExact(PyObject *ob)¶
ob가
PyDateTime_DateType
형이면 참을 돌려줍니다. ob는NULL
이 아니어야 합니다. 이 함수는 항상 성공합니다.
-
int PyDateTime_Check(PyObject *ob)¶
ob가
PyDateTime_DateTimeType
형이거나PyDateTime_DateTimeType
의 서브 형이면 참을 돌려줍니다. ob는NULL
이 아니어야 합니다. 이 함수는 항상 성공합니다.
-
int PyDateTime_CheckExact(PyObject *ob)¶
ob가
PyDateTime_DateTimeType
형이면 참을 돌려줍니다. ob는NULL
이 아니어야 합니다. 이 함수는 항상 성공합니다.
-
int PyTime_Check(PyObject *ob)¶
ob가
PyDateTime_TimeType
형이거나PyDateTime_TimeType
의 서브 형이면 참을 돌려줍니다. ob는NULL
이 아니어야 합니다. 이 함수는 항상 성공합니다.
-
int PyTime_CheckExact(PyObject *ob)¶
ob가
PyDateTime_TimeType
형이면 참을 돌려줍니다. ob는NULL
이 아니어야 합니다. 이 함수는 항상 성공합니다.
-
int PyDelta_Check(PyObject *ob)¶
ob가
PyDateTime_DeltaType
형이거나PyDateTime_DeltaType
의 서브 형이면 참을 돌려줍니다. ob는NULL
이 아니어야 합니다. 이 함수는 항상 성공합니다.
-
int PyDelta_CheckExact(PyObject *ob)¶
ob가
PyDateTime_DeltaType
형이면 참을 돌려줍니다. ob는NULL
이 아니어야 합니다. 이 함수는 항상 성공합니다.
-
int PyTZInfo_Check(PyObject *ob)¶
ob가
PyDateTime_TZInfoType
형이거나PyDateTime_TZInfoType
의 서브 형이면 참을 돌려줍니다. ob는NULL
이 아니어야 합니다. 이 함수는 항상 성공합니다.
-
int PyTZInfo_CheckExact(PyObject *ob)¶
ob가
PyDateTime_TZInfoType
형이면 참을 돌려줍니다. ob는NULL
이 아니어야 합니다. 이 함수는 항상 성공합니다.
객체를 만드는 매크로:
-
PyObject *PyDate_FromDate(int year, int month, int day)¶
- 반환값: 새 참조.
지정된 년, 월, 일의
datetime.date
객체를 반환합니다.
-
PyObject *PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond)¶
- 반환값: 새 참조.
지정된 년, 월, 일, 시, 분, 초 및 마이크로초의
datetime.datetime
객체를 반환합니다.
-
PyObject *PyDateTime_FromDateAndTimeAndFold(int year, int month, int day, int hour, int minute, int second, int usecond, int fold)¶
- 반환값: 새 참조.
지정된 년, 월, 일, 시, 분, 초, 마이크로초 및 fold의
datetime.datetime
객체를 반환합니다.Added in version 3.6.
-
PyObject *PyTime_FromTime(int hour, int minute, int second, int usecond)¶
- 반환값: 새 참조.
지정된 시, 분, 초 및 마이크로초의
datetime.time
객체를 반환합니다.
-
PyObject *PyTime_FromTimeAndFold(int hour, int minute, int second, int usecond, int fold)¶
- 반환값: 새 참조.
지정된 시, 분, 초, 마이크로초 및 fold의
datetime.time
객체를 반환합니다.Added in version 3.6.
-
PyObject *PyDelta_FromDSU(int days, int seconds, int useconds)¶
- 반환값: 새 참조.
지정된 일, 초 및 마이크로초 수를 나타내는
datetime.timedelta
객체를 반환합니다. 결과 마이크로초와 초가datetime.timedelta
객체에 관해 설명된 범위에 있도록 정규화가 수행됩니다.
-
PyObject *PyTimeZone_FromOffset(PyObject *offset)¶
- 반환값: 새 참조.
offset 인자로 나타내지는 이름이 없는 고정 오프셋의
datetime.timezone
객체를 돌려줍니다.Added in version 3.7.
-
PyObject *PyTimeZone_FromOffsetAndName(PyObject *offset, PyObject *name)¶
- 반환값: 새 참조.
offset 인자와 tzname name으로 나타내지는 고정 오프셋의
datetime.timezone
객체를 돌려줍니다.Added in version 3.7.
날짜 객체에서 필드를 추출하는 매크로. 인자는 서브 클래스(가령 PyDateTime_DateTime
)를 포함하여 PyDateTime_Date
의 인스턴스여야 합니다. 인자는 NULL
이 아니어야 하며, 형은 검사하지 않습니다:
-
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로, 일을 반환합니다.
날짜 시간 객체에서 필드를 추출하는 매크로. 인자는 서브 클래스를 포함하여 PyDateTime_DateTime
의 인스턴스여야 합니다. 인자는 NULL
이 아니어야 하며, 형은 검사하지 않습니다.:
-
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)¶
0에서 1까지의 int로, 폴드를 반환합니다.
Added in version 3.6.
-
PyObject *PyDateTime_DATE_GET_TZINFO(PyDateTime_DateTime *o)¶
Return the tzinfo (which may be
None
).Added in version 3.10.
시간 객체에서 필드를 추출하는 매크로. 인자는 서브 클래스를 포함하여 PyDateTime_Time
의 인스턴스여야 합니다. 인자는 NULL
이 아니어야 하며 형은 검사하지 않습니다:
-
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)¶
0에서 1까지의 int로, 폴드를 반환합니다.
Added in version 3.6.
-
PyObject *PyDateTime_TIME_GET_TZINFO(PyDateTime_Time *o)¶
Return the tzinfo (which may be
None
).Added in version 3.10.
시간 델타 객체에서 필드를 추출하는 매크로. 인자는 서브 클래스를 포함하여 PyDateTime_Delta
의 인스턴스여야 합니다. 인자는 NULL
이 아니어야 하며 형은 검사하지 않습니다.:
-
int PyDateTime_DELTA_GET_DAYS(PyDateTime_Delta *o)¶
-999999999에서 999999999까지의 int로, 일 수를 반환합니다.
Added in version 3.3.
-
int PyDateTime_DELTA_GET_SECONDS(PyDateTime_Delta *o)¶
0부터 86399까지의 int로, 초 수를 반환합니다.
Added in version 3.3.
-
int PyDateTime_DELTA_GET_MICROSECONDS(PyDateTime_Delta *o)¶
0에서 999999까지의 int로, 마이크로초 수를 반환합니다.
Added in version 3.3.
DB API를 구현하는 모듈의 편의를 위한 매크로:
-
PyObject *PyDateTime_FromTimestamp(PyObject *args)¶
- 반환값: 새 참조.
datetime.datetime.fromtimestamp()
에 전달하는 데 적합한 인자 튜플로 새datetime.datetime
객체를 만들고 반환합니다.
-
PyObject *PyDate_FromTimestamp(PyObject *args)¶
- 반환값: 새 참조.
datetime.date.fromtimestamp()
에 전달하는 데 적합한 인자 튜플로 새datetime.date
객체를 만들고 반환합니다.