just can't get it right, try again ....

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8806 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2003-06-30 04:57:52 +00:00
parent 6baae8eeef
commit 19cd206dcd
2 changed files with 27 additions and 27 deletions

View File

@ -412,7 +412,7 @@ const gchar *qof_date_format_get_format(QofDateFormat df)
} }
/** /**
* qof_print_date_buff * qof_print_date_dmy_buff
* Convert a date as day / month / year integers into a localized string * Convert a date as day / month / year integers into a localized string
* representation * representation
* *
@ -427,7 +427,7 @@ const gchar *qof_date_format_get_format(QofDateFormat df)
* Globals: global dateFormat value * Globals: global dateFormat value
*/ */
size_t size_t
qof_print_date_buff (char * buff, size_t len, int day, int month, int year) qof_print_date_dmy_buff (char * buff, size_t len, int day, int month, int year)
{ {
int flen; int flen;
if (!buff) return 0; if (!buff) return 0;
@ -474,35 +474,35 @@ qof_print_date_buff (char * buff, size_t len, int day, int month, int year)
return flen; return flen;
} }
void size_t
qof_print_date_secs_buff (char * buff, time_t t) qof_print_date_buff (char * buff, size_t len, time_t t)
{ {
struct tm *theTime; struct tm *theTime;
if (!buff) return; if (!buff) return 0 ;
theTime = localtime (&t); theTime = localtime (&t);
qof_print_date_buff (buff, MAX_DATE_LENGTH, return qof_print_date_dmy_buff (buff, len,
theTime->tm_mday, theTime->tm_mday,
theTime->tm_mon + 1, theTime->tm_mon + 1,
theTime->tm_year + 1900); theTime->tm_year + 1900);
} }
void size_t
qof_print_gdate( char *buf, GDate *gd ) qof_print_gdate( char *buf, size_t len, GDate *gd )
{ {
qof_print_date_buff( buf, MAX_DATE_LENGTH, return qof_print_date_dmy_buff( buf, len,
g_date_day(gd), g_date_day(gd),
g_date_month(gd), g_date_month(gd),
g_date_year(gd) ); g_date_year(gd) );
} }
char * char *
qof_print_date_secs (time_t t) qof_print_date (time_t t)
{ {
char buff[MAX_DATE_LENGTH]; char buff[MAX_DATE_LENGTH];
qof_print_date_secs_buff (buff, t); qof_print_date_buff (buff, MAX_DATE_LENGTH, t);
return g_strdup (buff); return g_strdup (buff);
} }
@ -514,7 +514,7 @@ gnc_print_date (Timespec ts)
t = ts.tv_sec + (ts.tv_nsec / 1000000000.0); t = ts.tv_sec + (ts.tv_nsec / 1000000000.0);
qof_print_date_secs_buff (buff, t); qof_print_date_buff (buff, MAX_DATE_LENGTH, t);
return buff; return buff;
} }

View File

@ -54,10 +54,10 @@
#define getDateFormat qof_date_format_get #define getDateFormat qof_date_format_get
#define setDateFormat qof_date_format_set #define setDateFormat qof_date_format_set
#define DateFormat QofDateFormat #define DateFormat QofDateFormat
#define printDateSecs qof_print_date_secs_buff #define printDateSecs(B,S) qof_print_date_buff(B,MAX_DATE_LENGTH,S)
#define printDate(S,D,M,Y) qof_print_date_buff(S,MAX_DATE_LENGTH,D,M,Y) #define printDate(B,D,M,Y) qof_print_date_dmy_buff(B,MAX_DATE_LENGTH,D,M,Y)
#define printGDate qof_print_gdate #define printGDate(B,D) qof_print_gdate(B,MAX_DATE_LENGTH,D)
#define xaccPrintDateSecs qof_print_date_secs #define xaccPrintDateSecs qof_print_date
#define scanDate qof_scan_date #define scanDate qof_scan_date
#define DATE_FORMAT_US QOF_DATE_FORMAT_US #define DATE_FORMAT_US QOF_DATE_FORMAT_US
@ -267,7 +267,7 @@ char dateSeparator(void);
* itself, instead of depending on the routines here. * itself, instead of depending on the routines here.
*/ */
/*@{*/ /*@{*/
/** qof_print_date_buff /** qof_print_date_dmy_buff
* Convert a date as day / month / year integers into a localized string * Convert a date as day / month / year integers into a localized string
* representation * representation
* *
@ -282,24 +282,24 @@ char dateSeparator(void);
* *
* Globals: global dateFormat value * Globals: global dateFormat value
**/ **/
size_t qof_print_date_buff (char * buff, size_t buflen, int day, int month, int year); size_t qof_print_date_dmy_buff (char * buff, size_t buflen, int day, int month, int year);
/** Convenience: calls through to qof_print_date_buff(). **/ /** Convenience: calls through to qof_print_date_dmy_buff(). **/
void qof_print_date_secs_buff (char * buff, time_t secs); size_t qof_print_date_buff (char * buff, size_t buflen, time_t secs);
/** Convenience; calls through to qof_print_date_buff(). **/ /** Convenience; calls through to qof_print_date_dmy_buff(). **/
void qof_print_gdate( char *buf, GDate *gd ); size_t qof_print_gdate( char *buf, size_t bufflen, GDate *gd );
/** Convenience; calls through to qof_print_date_buff(). /** Convenience; calls through to qof_print_date_dmy_buff().
* Return: string, which should be freed when no longer needed. * Return: string, which should be freed when no longer needed.
* **/ * **/
char * qof_print_date_secs (time_t secs); char * qof_print_date (time_t secs);
/** Convenience; calls through to qof_print_date_buff(). /** Convenience; calls through to qof_print_date_dmy_buff().
* Return: static global string. * Return: static global string.
* \warning This routine is not thread-safe, because it uses a single * \warning This routine is not thread-safe, because it uses a single
* global buffer to store the return value. Use qof_print_date_secs_buff() * global buffer to store the return value. Use qof_print_date_buff()
* or qof_print_date_secs instead. * or qof_print_date() instead.
* **/ * **/
const char * gnc_print_date(Timespec ts); const char * gnc_print_date(Timespec ts);