[Mono-list] Re: OCIDateTime

Hubert FONGARNAND informatique.internet@fiducial.fr
Mon, 18 Apr 2005 16:33:54 +0200


Thank you for your answer...
I would like to use OCIDateTimeConstruct to build a OCIDateTime descripto=
r...
in order to transform it into a byte array via the OCIDateTimeToArray=20
function...

I've imported the OCIDateTimeConstruct in OCIcalls.cs

[DllImport ("oci")]
internal static extern int OCIDateTimeConstruct (IntPtr hndl,
				IntPtr err, IntPtr datetime, short year, byte month, byte day, byte h=
our,=20
byte min, byte sec, uint fsec, byte[] timezone, uint timezone_length);

my code :

IntPtr datetimepointer;
// allocating memory for OCIDateTime
datetimepointer =3D Marshal.AllocHGlobal (7); // size of an OCIDateTime
// Get size of buffer
string mytimezone =3D "GMT";
int =A0timesize =3D 0;
// Get size of buffer
OciCalls.OCIUnicodeToCharSet (statement.Parent, null, mytimezone, out=20
timesize);
// Fill buffer
byte[] mybytes =3D new byte[timesize];
OciCalls.OCIUnicodeToCharSet (statement.Parent, bytes, mytimezone, out=20=

timesize);
int err=3DOciCalls.OCIDateTimeConstruct(statement.Parent,connection.Error=
Handle,=20
datetimepointer, 2005,4,18,15,0,0,0,mybytes,(uint)timesize);

I got a -2 error, the documentation tells me that the OCIDateTime descrip=
tor=20
is bad...
How can I allocate a correct OCIDateTime descriptor????
(in c :=20
OCIDateTime mydatetime;)




Le Vendredi 15 Avril 2005 20:04, vous avez =E9crit=A0:
> OCIDate is an opaque C data type.
>
> Take a look at UnpackDate in OciDefineHandle.cs
>
> public DateTime UnpackDate ()
> {
> byte century =3D Marshal.ReadByte (value, 0);
> byte year =3D Marshal.ReadByte (value, 1);
> byte month =3D Marshal.ReadByte (value, 2);
> byte day =3D Marshal.ReadByte (value, 3);
> byte hour =3D Marshal.ReadByte (value, 4);
> byte minute =3D Marshal.ReadByte (value, 5);
> byte second =3D Marshal.ReadByte (value, 6);
>
> return new DateTime ((century - 100) * 100 + (year - 100),
> month,
> day,
> hour - 1,
> minute - 1,
> second - 1);
>
> }
>
> Note: there are these functions too which maybe a better way to get/set=

> date and time.
>
> OCIDateSetTime / OCIDataGetTime
> OCIDateSetDate / OCIDateGetDate
>
>
>
>
>
>   _____
>
> Yahoo! Mail Mobile
> Take Yahoo! Mail with you!
> <http://us.rd.yahoo.com/mail_us/taglines/mobile/*http://mobile.yahoo.co=
m
> /learn/mail>  Check email on your mobile phone.
_______________________________________________
Ce message et les =E9ventuels documents joints peuvent contenir des infor=
mations confidentielles.
Au cas o=F9 il ne vous serait pas destin=E9, nous vous remercions de bien=
 vouloir le supprimer et en aviser imm=E9diatement l'exp=E9diteur. Toute =
utilisation de ce message non conforme =E0 sa destination, toute diffusio=
n ou publication, totale ou partielle et quel qu'en soit le moyen est for=
mellement interdite.
Les communications sur internet n'=E9tant pas s=E9curis=E9es, l'int=E9gri=
t=E9 de ce message n'est pas assur=E9e et la soci=E9t=E9 =E9mettrice ne p=
eut =EAtre tenue pour responsable de son contenu.