diff --git a/ChangeLog b/ChangeLog index fc7c3ff7b3..e0a10e22a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,18 @@ Consolidate all the functions that convert time values to be the beginning, middle, or end of a day. + * src/backend/file/gnc-backend-file.c: + * src/backend/file/io-gncbin-r.c: + * src/engine/Makefile.am: + * src/engine/TransLog.c: + * src/engine/date.c: + * src/engine/date.h: + * src/engine/gnc-book.c: + * src/engine/gnc-session-scm.c: + * src/engine/gnc-session.c: + * src/optional/swig/Makefile.am: + Collapse the DateUtils.[ch] files into date.[ch]. + 2003-03-15 David Hampton * src/gnome-utils/gnc-date-edit.c: Fix the keypress handlers so diff --git a/src/backend/file/gnc-backend-file.c b/src/backend/file/gnc-backend-file.c index 98f73db5bd..bdb93bf991 100644 --- a/src/backend/file/gnc-backend-file.c +++ b/src/backend/file/gnc-backend-file.c @@ -24,7 +24,7 @@ #include "TransLog.h" #include "gnc-engine-util.h" #include "gnc-pricedb-p.h" -#include "DateUtils.h" +#include "date.h" #include "io-gncxml.h" #include "io-gncbin.h" #include "io-gncxml-v2.h" diff --git a/src/backend/file/io-gncbin-r.c b/src/backend/file/io-gncbin-r.c index 490cd8d11e..0b15ac5d86 100644 --- a/src/backend/file/io-gncbin-r.c +++ b/src/backend/file/io-gncbin-r.c @@ -96,7 +96,6 @@ #include "AccountP.h" #include "Backend.h" #include "date.h" -#include "DateUtils.h" #include "io-gncbin.h" #include "Group.h" #include "GroupP.h" diff --git a/src/engine/DateUtils.c b/src/engine/DateUtils.c deleted file mode 100644 index 99f3a4c16b..0000000000 --- a/src/engine/DateUtils.c +++ /dev/null @@ -1,71 +0,0 @@ -/********************************************************************\ - * DateUtils.c -- Date Handling Utilities * - * Copyright (C) 1998 Linas Vepstas * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 2 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License* - * along with this program; if not, contact: * - * * - * Free Software Foundation Voice: +1-617-542-5942 * - * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * - * Boston, MA 02111-1307, USA gnu@gnu.org * - * * -\********************************************************************/ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "DateUtils.h" - -#define BUFFSIZE 100 - - -/* ======================================================== */ -char * -xaccDateUtilGetStamp (time_t thyme) -{ - struct tm *stm; - char buf[BUFFSIZE]; - char * retval; - - stm = localtime (&thyme); - - sprintf (buf, "%04d%02d%02d%02d%02d%02d", - (stm->tm_year + 1900), - (stm->tm_mon +1), - stm->tm_mday, - stm->tm_hour, - stm->tm_min, - stm->tm_sec - ); - - retval = g_strdup (buf); - return retval; -} - -/* ======================================================== */ - -char * -xaccDateUtilGetStampNow (void) -{ - time_t now; - time (&now); - return xaccDateUtilGetStamp (now); -} - -/************************ END OF ************************************\ -\************************* FILE *************************************/ diff --git a/src/engine/DateUtils.h b/src/engine/DateUtils.h deleted file mode 100644 index a70de67c93..0000000000 --- a/src/engine/DateUtils.h +++ /dev/null @@ -1,37 +0,0 @@ -/********************************************************************\ - * DateUtils.h -- Date Handling Utilities * - * Copyright (C) 1998 Linas Vepstas * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 2 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License* - * along with this program; if not, contact: * - * * - * Free Software Foundation Voice: +1-617-542-5942 * - * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * - * Boston, MA 02111-1307, USA gnu@gnu.org * - * * -\********************************************************************/ - -#ifndef XACC_DATE_UTILS_H -#define XACC_DATE_UTILS_H - -#include - -#include "config.h" - -char * xaccDateUtilGetStamp (time_t thyme); -char * xaccDateUtilGetStampNow (void); - -#endif /* XACC_DATE_UTILS_H */ - -/************************ END OF ************************************\ -\************************* FILE *************************************/ diff --git a/src/engine/Makefile.am b/src/engine/Makefile.am index f9569a13ec..1c841404ed 100644 --- a/src/engine/Makefile.am +++ b/src/engine/Makefile.am @@ -11,7 +11,6 @@ AM_CFLAGS = \ libgncmod_engine_la_SOURCES = \ Account.c \ Backend.c \ - DateUtils.c \ FreqSpec.c \ GNCId.c \ Group.c \ @@ -51,7 +50,6 @@ gncincludedir = ${GNC_INCLUDE_DIR} gncinclude_HEADERS = \ Account.h \ Backend.h \ - DateUtils.h \ FreqSpec.h \ GNCId.h \ Group.h \ diff --git a/src/engine/TransLog.c b/src/engine/TransLog.c index af2c22ab54..5c270af084 100644 --- a/src/engine/TransLog.c +++ b/src/engine/TransLog.c @@ -31,7 +31,6 @@ #include "Account.h" #include "AccountP.h" -#include "DateUtils.h" #include "date.h" #include "Transaction.h" #include "TransactionP.h" diff --git a/src/engine/date.c b/src/engine/date.c index 610901192c..0c5f4897d1 100644 --- a/src/engine/date.c +++ b/src/engine/date.c @@ -983,6 +983,27 @@ gnc_timet_get_day_end (time_t time_val) return mktime(&tm); } +/* The xaccDateUtilGetStamp() routine will take the given time in + * seconds and return a buffer containing a textual for the date. */ +char * +xaccDateUtilGetStamp (time_t thyme) +{ + struct tm *stm; + + stm = localtime (&thyme); + + return g_strdup_printf("%04d%02d%02d%02d%02d%02d", + (stm->tm_year + 1900), + (stm->tm_mon +1), + stm->tm_mday, + stm->tm_hour, + stm->tm_min, + stm->tm_sec + ); +} + +/* ======================================================== */ + void gnc_tm_get_today_start (struct tm *tm) { @@ -1013,5 +1034,16 @@ gnc_timet_get_today_end (void) return mktime(&tm); } +/* The xaccDateUtilGetStampNow() routine returns the current time in + * seconds in textual format. */ +char * +xaccDateUtilGetStampNow (void) +{ + time_t now; + time (&now); + return xaccDateUtilGetStamp (now); +} + + /********************** END OF FILE *********************************\ \********************************************************************/ diff --git a/src/engine/date.h b/src/engine/date.h index 506f1cec08..691f86e023 100644 --- a/src/engine/date.h +++ b/src/engine/date.h @@ -310,6 +310,15 @@ time_t gnc_timet_get_day_start(time_t time_val); * seconds and adjust it to the last second of that day. */ time_t gnc_timet_get_day_end(time_t time_val); +/** The xaccDateUtilGetStamp() routine will take the given time in + * seconds and return a buffer containing a textual for the date. + * @param thyme The time in seconds to convert. + * @return A pointer to the generated string. + * @note The caller owns this buffer and must free it when done. */ +char *xaccDateUtilGetStamp (time_t thyme); + +/* ======================================================== */ + /** The gnc_tm_get_today_start() routine takes a pointer to a struct * tm and fills it in with the first second of the today. */ void gnc_tm_get_today_start(struct tm *tm); @@ -325,6 +334,13 @@ time_t gnc_timet_get_today_start(void); /** The gnc_timet_get_today_end() routine returns a time_t value * corresponding to the last second of today. */ time_t gnc_timet_get_today_end(void); + +/** The xaccDateUtilGetStampNow() routine returns the current time in + * seconds in textual format. + * @return A pointer to the generated string. + * @note The caller owns this buffer and must free it when done. */ +char *xaccDateUtilGetStampNow (void); + /** @} */ #endif /* XACC_DATE_H */ diff --git a/src/engine/gnc-book.c b/src/engine/gnc-book.c index c100f6837e..a9291fe80c 100644 --- a/src/engine/gnc-book.c +++ b/src/engine/gnc-book.c @@ -52,7 +52,7 @@ #include "engine-helpers.h" #include "gnc-engine-util.h" #include "gnc-pricedb-p.h" -#include "DateUtils.h" +#include "date.h" #include "gnc-book.h" #include "gnc-book-p.h" #include "gnc-engine.h" diff --git a/src/engine/gnc-session-scm.c b/src/engine/gnc-session-scm.c index db9beaab77..a6f38be27f 100644 --- a/src/engine/gnc-session-scm.c +++ b/src/engine/gnc-session-scm.c @@ -46,7 +46,7 @@ #include "BackendP.h" #include "TransLog.h" #include "gnc-engine-util.h" -#include "DateUtils.h" +#include "date.h" #include "gnc-book-p.h" #include "gnc-engine.h" #include "gnc-engine-util.h" diff --git a/src/engine/gnc-session.c b/src/engine/gnc-session.c index 85ea340506..80f1096dcb 100644 --- a/src/engine/gnc-session.c +++ b/src/engine/gnc-session.c @@ -46,7 +46,7 @@ #include "BackendP.h" #include "TransLog.h" #include "gnc-engine-util.h" -#include "DateUtils.h" +#include "date.h" #include "gnc-book-p.h" #include "gnc-engine.h" #include "gnc-engine-util.h" diff --git a/src/optional/swig/Makefile.am b/src/optional/swig/Makefile.am index 9446e66eda..0e539df3ab 100644 --- a/src/optional/swig/Makefile.am +++ b/src/optional/swig/Makefile.am @@ -51,7 +51,6 @@ libgncswig_la_LIBADD = \ SWIG_INPUT_HDRS := \ ${top_srcdir}/src/engine/Account.h \ - ${top_srcdir}/src/engine/DateUtils.h \ ${top_srcdir}/src/engine/GNCId.h \ ${top_srcdir}/src/engine/Group.h \ ${top_srcdir}/src/engine/Query.h \