Skip site navigation (1) Skip section navigation (2)

my strftime func doesn't work. please help.

From: Zsolt Varga <redax(at)agria(dot)hu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: my strftime func doesn't work. please help.
Date: 1998-06-13 07:08:38
Message-ID: Pine.LNX.3.96.980613090136.2367D-100000@lupus.agria.hu (view raw or flat)
Thread:
Lists: pgsql-hackers
hello!

I tried to make a function, like strftime in C
called pstrtime( format, date )

here's the source... but when I compile it and create the function
under 6.3.2 first time it gives back an emty string.. after the backend 
stops ;(

please correct my faults,
----------------------------------------------------------------------
#include <stdio.h>                              /* for sprintf() */
#include <string.h>
#include <limits.h>
#include "postgres.h"
#include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/nabstime.h"
#include "utils/datetime.h"
#include "access/xact.h"

#define JDATE_2000      2451545

char       *pstrtime(char *format, DateADT val);


char *
pstrtime( char *format , DateADT val)
{
        int                     year,
                                month,
                                day;
        struct tm * time1;
        char *sometext;
        sometext = malloc(100);
        time1 = malloc(sizeof(struct tm));

        j2date(val + JDATE_2000, &year, &month, &day);

        time1->tm_year=year;
        time1->tm_mon=month-1;
        time1->tm_mday=day;

        strftime(sometext,90,format,time1 );
        free(time1);
        return( sometext );
}


anyway how to create this function under psql ?
C type               postgres type
-----------------------------------
DateADT			date
char * 			???????????

thanks,

	Best regards, 
		Redax
.----------------------------------------------------------.
|Zsolt Varga            | tel/fax:   +36 36 422811         |
| AgriaComputer LTD     | email:     redax(at)agria(dot)hu        |
| System Administrator  | URL:       http://www.agria.hu/  |
`----------------------------------------------------------'


Responses

pgsql-hackers by date

Next:From: David GouldDate: 1998-06-13 07:11:22
Subject: Re: [HACKERS] update by one transaction
Previous:From: Vadim MikheevDate: 1998-06-13 06:18:05
Subject: Re: [BUGS] NOTICE:AbortTransaction and not in in-progress state

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group