a32bb8df67efcef2f178901fd396b2230c1b7281
[plcapi.git] / psycopg2 / psycopg / adapter_datetime.h
1 /* adapter_datetime.h - definition for the python date/time types
2  *
3  * Copyright (C) 2004 Federico Di Gregorio <fog@debian.org>
4  *
5  * This file is part of psycopg.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2,
10  * or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21
22 #ifndef PSYCOPG_DATETIME_H
23 #define PSYCOPG_DATETIME_H 1
24
25 #include <Python.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 extern PyTypeObject pydatetimeType;
32
33 typedef struct {
34     PyObject HEAD;
35
36     PyObject *wrapped;
37     int       type;
38 #define       PSYCO_DATETIME_TIME       0
39 #define       PSYCO_DATETIME_DATE       1
40 #define       PSYCO_DATETIME_TIMESTAMP  2
41 #define       PSYCO_DATETIME_INTERVAL   3    
42     
43 } pydatetimeObject;
44     
45     
46 /* functions exported to psycopgmodule.c */
47 #ifdef PSYCOPG_DEFAULT_PYDATETIME
48     
49 extern PyObject *psyco_Date(PyObject *module, PyObject *args);
50 #define psyco_Date_doc \
51     "Date(year, month, day) -> new date\n\n" \
52     "Build an object holding a date value."
53
54 extern PyObject *psyco_Time(PyObject *module, PyObject *args);
55 #define psyco_Time_doc \
56     "Time(hour, minutes, seconds, tzinfo=None) -> new time\n\n" \
57     "Build an object holding a time value."
58
59 extern PyObject *psyco_Timestamp(PyObject *module, PyObject *args);
60 #define psyco_Timestamp_doc \
61     "Timestamp(year, month, day, hour, minutes, seconds, tzinfo=None) -> new timestamp\n\n" \
62     "Build an object holding a timestamp value."
63
64 extern PyObject *psyco_DateFromTicks(PyObject *module, PyObject *args);
65 #define psyco_DateFromTicks_doc \
66     "DateFromTicks(ticks) -> new date\n\n" \
67     "Build an object holding a date value from the given ticks value.\n\n" \
68     "Ticks are the number of seconds since the epoch; see the documentation " \
69     "of the standard Python time module for details)."
70
71 extern PyObject *psyco_TimeFromTicks(PyObject *module, PyObject *args);
72 #define psyco_TimeFromTicks_doc \
73     "TimeFromTicks(ticks) -> new time\n\n" \
74     "Build an object holding a time value from the given ticks value.\n\n" \
75     "Ticks are the number of seconds since the epoch; see the documentation " \
76     "of the standard Python time module for details)."
77
78 extern PyObject *psyco_TimestampFromTicks(PyObject *module, PyObject *args);
79 #define psyco_TimestampFromTicks_doc \
80     "TimestampFromTicks(ticks) -> new timestamp\n\n" \
81     "Build an object holding a timestamp value from the given ticks value.\n\n" \
82     "Ticks are the number of seconds since the epoch; see the documentation " \
83     "of the standard Python time module for details)."
84
85 #endif /* PSYCOPG_DEFAULT_PYDATETIME */
86
87 extern PyObject *psyco_DateFromPy(PyObject *module, PyObject *args);
88 #define psyco_DateFromPy_doc \
89     "DateFromPy(datetime.date) -> new wrapper"
90
91 extern PyObject *psyco_TimeFromPy(PyObject *module, PyObject *args);
92 #define psyco_TimeFromPy_doc \
93     "TimeFromPy(datetime.time) -> new wrapper"
94
95 extern PyObject *psyco_TimestampFromPy(PyObject *module, PyObject *args);
96 #define psyco_TimestampFromPy_doc \
97     "TimestampFromPy(datetime.datetime) -> new wrapper"
98
99 extern PyObject *psyco_IntervalFromPy(PyObject *module, PyObject *args);
100 #define psyco_IntervalFromPy_doc \
101     "IntervalFromPy(datetime.timedelta) -> new wrapper"
102     
103 #ifdef __cplusplus
104 }
105 #endif
106
107 #endif /* !defined(PSYCOPG_DATETIME_H) */