DateTime オブジェクト
*********************

"datetime" モジュールでは、様々な日付オブジェクトや時刻オブジェクトを
提供しています。以下に示す関数を使う場合には、あらかじめヘッダファイル
"datetime.h" をソースに include し ("Python.h" はこのファイルを
include しません)、 "PyDateTime_IMPORT" マクロを、通常はモジュール初期
化関数から、起動しておく必要があります。このマクロは以下のマクロで使わ
れる静的変数 "PyDateTimeAPI" に C 構造体へのポインタを入れます。

型チェックマクロ:

int PyDate_Check(PyObject *ob)

   *ob* が "PyDateTime_DateType" 型か "PyDateTime_DateType" 型のサブタ
   イプのオブジェクトの場合に真を返します; *ob* は *NULL* であってはな
   りません。

   バージョン 2.4 で追加.

int PyDate_CheckExact(PyObject *ob)

   *ob* が "PyDateTime_DateType" 型のオブジェクトの場合に真を返します;
   *ob* は *NULL* であってはなりません。

   バージョン 2.4 で追加.

int PyDateTime_Check(PyObject *ob)

   *ob* が "PyDateTime_DateTimeType" 型か "PyDateTime_DateTimeType" 型
   のサブタイプのオブジェクトの場合に真を返します; *ob* は *NULL* であ
   ってはなりません。

   バージョン 2.4 で追加.

int PyDateTime_CheckExact(PyObject *ob)

   *ob* が "PyDateTime_DateTimeType" 型のオブジェクトの場合に真を返し
   ます; *ob* は *NULL* であってはなりません。

   バージョン 2.4 で追加.

int PyTime_Check(PyObject *ob)

   *ob* が "PyDateTime_TimeType" 型か "PyDateTime_TimeType" 型のサブタ
   イプのオブジェクトの場合に真を返します; *ob* は *NULL* であってはな
   りません。

   バージョン 2.4 で追加.

int PyTime_CheckExact(PyObject *ob)

   *ob* が "PyDateTime_TimeType" 型のオブジェクトの場合に真を返します;
   *ob* は *NULL* であってはなりません。

   バージョン 2.4 で追加.

int PyDelta_Check(PyObject *ob)

   *ob* が "PyDateTime_DeltaType" 型か "PyDateTime_DeltaType" 型のサブ
   タイプのオブジェクトの場合に真を返します; *ob* は *NULL* であっては
   なりません。

   バージョン 2.4 で追加.

int PyDelta_CheckExact(PyObject *ob)

   *ob* が "PyDateTime_DeltaType" 型のオブジェクトの場合に真を返します
   ; *ob* は *NULL* であってはなりません。

   バージョン 2.4 で追加.

int PyTZInfo_Check(PyObject *ob)

   *ob* が "PyDateTime_TZInfoType" 型か "PyDateTime_TZInfoType" 型のサ
   ブタイプのオブジェクトの場合に真を返します; *ob* は *NULL* であって
   はなりません。

   バージョン 2.4 で追加.

int PyTZInfo_CheckExact(PyObject *ob)

   *ob* が "PyDateTime_TZInfoType" 型のオブジェクトの場合に真を返しま
   す; *ob* は *NULL* であってはなりません。

   バージョン 2.4 で追加.

以下はオブジェクトを作成するためのマクロです:

PyObject* PyDate_FromDate(int year, int month, int day)
    *Return value: New reference.*

   指定された年、月、日の "datetime.date" オブジェクトを返します。

   バージョン 2.4 で追加.

PyObject* PyDateTime_FromDateAndTime(int year, int month, int day, int hour, int minute, int second, int usecond)
    *Return value: New reference.*

   指定された年、月、日、時、分、秒、マイクロ秒の "datetime.datetime"
   オブジェクトを返します。

   バージョン 2.4 で追加.

PyObject* PyTime_FromTime(int hour, int minute, int second, int usecond)
    *Return value: New reference.*

   指定された時、分、秒、マイクロ秒の "datetime.time" オブジェクトを返
   します。

   バージョン 2.4 で追加.

PyObject* PyDelta_FromDSU(int days, int seconds, int useconds)
    *Return value: New reference.*

   指定された日、秒、マイクロ秒の "datetime.timedelta" オブジェクトを
   返します。マイクロ秒と秒が "datetime.timedelta" オブジェクトで定義
   されている範囲に入るように正規化を行います。

   バージョン 2.4 で追加.

以下のマクロは date オブジェクトからフィールド値を取り出すためのもので
す。引数は "PyDateTime_Date" またはそのサブクラス (例えば
"PyDateTime_DateTime")の  インスタンスでなければなりません。引数を
*NULL* にしてはならず、型チェックは行いません:

int PyDateTime_GET_YEAR(PyDateTime_Date *o)

   年を正の整数で返します。

   バージョン 2.4 で追加.

int PyDateTime_GET_MONTH(PyDateTime_Date *o)

   月を 1 から 12 の間の整数で返します。

   バージョン 2.4 で追加.

int PyDateTime_GET_DAY(PyDateTime_Date *o)

   日を 1 から 31 の間の整数で返します。

   バージョン 2.4 で追加.

以下のマクロは datetime オブジェクトからフィールド値を取り出すためのも
のです。引数は "PyDateTime_DateTime" またはそのサブクラスのインスタン
スでなければなりません。引数を *NULL* にしてはならず、型チェックは行い
ません:

int PyDateTime_DATE_GET_HOUR(PyDateTime_DateTime *o)

   時を 0 から 23 の間の整数で返します。

   バージョン 2.4 で追加.

int PyDateTime_DATE_GET_MINUTE(PyDateTime_DateTime *o)

   分を 0 から 59 の間の整数で返します。

   バージョン 2.4 で追加.

int PyDateTime_DATE_GET_SECOND(PyDateTime_DateTime *o)

   秒を 0 から 59 の間の整数で返します。

   バージョン 2.4 で追加.

int PyDateTime_DATE_GET_MICROSECOND(PyDateTime_DateTime *o)

   マイクロ秒を 0 から 999999 の間の整数で返します。

   バージョン 2.4 で追加.

以下のマクロは time オブジェクトからフィールド値を取り出すためのもので
す。引数は "PyDateTime_Time" またはそのサブクラスのインスタンスでなけ
ればなりません。引数を *NULL* にしてはならず、型チェックは行いません:

int PyDateTime_TIME_GET_HOUR(PyDateTime_Time *o)

   時を 0 から 23 の間の整数で返します。

   バージョン 2.4 で追加.

int PyDateTime_TIME_GET_MINUTE(PyDateTime_Time *o)

   分を 0 から 59 の間の整数で返します。

   バージョン 2.4 で追加.

int PyDateTime_TIME_GET_SECOND(PyDateTime_Time *o)

   秒を 0 から 59 の間の整数で返します。

   バージョン 2.4 で追加.

int PyDateTime_TIME_GET_MICROSECOND(PyDateTime_Time *o)

   マイクロ秒を 0 から 999999 の間の整数で返します。

   バージョン 2.4 で追加.

以下のマクロは DB API を実装する上での便宜用です:

PyObject* PyDateTime_FromTimestamp(PyObject *args)
    *Return value: New reference.*

   "datetime.datetime.fromtimestamp()" に渡すのに適した引数タプルから
   新たな "datetime.datetime" オブジェクトを生成して返します。

   バージョン 2.4 で追加.

PyObject* PyDate_FromTimestamp(PyObject *args)
    *Return value: New reference.*

   "datetime.date.fromtimestamp()" に渡すのに適した引数タプルから新た
   な "datetime.date" オブジェクトを生成して返します。

   バージョン 2.4 で追加.
