mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Rewrite and rename xaccDateUtilGetStampNow to gnc_date_timestamp.
Removing an ugly and antiquated name and providing a more concise implementation. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22608 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
c6c17fb34e
commit
880d3d301c
@ -665,7 +665,7 @@ gnc_xml_be_backup_file(FileBackend *be)
|
||||
}
|
||||
}
|
||||
|
||||
timestamp = xaccDateUtilGetStampNow ();
|
||||
timestamp = gnc_date_timestamp ();
|
||||
backup = g_strconcat( datafile, ".", timestamp, GNC_DATAFILE_EXT, NULL );
|
||||
g_free (timestamp);
|
||||
|
||||
|
@ -163,7 +163,7 @@ xaccOpenLog (void)
|
||||
if (!log_base_name) log_base_name = g_strdup ("translog");
|
||||
|
||||
/* tag each filename with a timestamp */
|
||||
timestamp = xaccDateUtilGetStampNow ();
|
||||
timestamp = gnc_date_timestamp ();
|
||||
|
||||
filename = g_strconcat (log_base_name, ".", timestamp, ".log", NULL);
|
||||
|
||||
|
@ -1369,21 +1369,11 @@ qof_strftime(gchar *buf, gsize max, const gchar *format, const struct tm *tm)
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
/** Return a string representation of the current local time.
|
||||
* @return string in YYYYMMDDHHmmss format. The string must be g_free()'d
|
||||
* by the caller.
|
||||
*/
|
||||
gchar *
|
||||
xaccDateUtilGetStampNow (void)
|
||||
gnc_date_timestamp (void)
|
||||
{
|
||||
GDateTime *gdt = g_date_time_new_now_local ();
|
||||
gchar *timestr = g_strdup_printf("%04d%02d%02d%02d%02d%02d",
|
||||
g_date_time_get_year (gdt),
|
||||
g_date_time_get_month (gdt),
|
||||
g_date_time_get_day_of_month (gdt),
|
||||
g_date_time_get_hour (gdt),
|
||||
g_date_time_get_minute (gdt),
|
||||
g_date_time_get_second (gdt));
|
||||
GDateTime *gdt = gnc_g_date_time_new_now_local ();
|
||||
gchar *timestr = g_date_time_format (gdt, "%Y%m%d%H%M%S");
|
||||
g_date_time_unref (gdt);
|
||||
return timestr;
|
||||
}
|
||||
|
@ -624,11 +624,10 @@ gint64 gnc_timet_get_today_start(void);
|
||||
* corresponding to the last second of today. */
|
||||
gint64 gnc_timet_get_today_end(void);
|
||||
|
||||
/** The xaccDateUtilGetStampNow() routine returns the current time in
|
||||
* seconds in textual format.
|
||||
/** \brief Make a timestamp in YYYYMMDDHHMMSS format.
|
||||
* @return A pointer to the generated string.
|
||||
* @note The caller owns this buffer and must free it when done. */
|
||||
char * xaccDateUtilGetStampNow (void);
|
||||
* @note The caller owns this buffer and must g_free it when done. */
|
||||
char * gnc_date_timestamp (void);
|
||||
|
||||
#define MIN_BUF_LEN 10
|
||||
/**
|
||||
|
@ -1543,22 +1543,15 @@ qof_strftime(gchar *buf, gsize max, const gchar *format, const struct tm *tm)//
|
||||
test_qof_strftime (void)
|
||||
{
|
||||
}*/
|
||||
/* xaccDateUtilGetStampNow
|
||||
/* gnc_date_timestamp
|
||||
gchar *
|
||||
xaccDateUtilGetStampNow (void)// C: 2 in 2 Local: 0:0:0
|
||||
gnc_date_timestamp (void)// C: 2 in 2 Local: 0:0:0
|
||||
*/
|
||||
static void
|
||||
test_xaccDateUtilGetStampNow (void)
|
||||
test_gnc_date_timestamp (void)
|
||||
{
|
||||
/* xaccDateUtilGetStampNow uses gdate, so in MinGW it gets UTC for
|
||||
* local because of the broken GTimeZone
|
||||
*/
|
||||
#ifdef G_OS_WIN32
|
||||
GDateTime *gdt = g_date_time_new_now_utc ();
|
||||
#else
|
||||
GDateTime *gdt = g_date_time_new_now_local ();
|
||||
#endif
|
||||
gchar *timestr = xaccDateUtilGetStampNow ();
|
||||
GDateTime *gdt = gncdt.new_now_local ();
|
||||
gchar *timestr = gnc_date_timestamp ();
|
||||
struct tm tm;
|
||||
|
||||
g_assert (strptime (timestr, "%Y%m%d%H%M%S", &tm));
|
||||
@ -2379,7 +2372,7 @@ test_suite_gnc_date (void)
|
||||
// GNC_TEST_ADD_FUNC (suitename, "qof formatted time to utf8", test_qof_formatted_time_to_utf8);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "qof format time", test_qof_format_time);
|
||||
// GNC_TEST_ADD_FUNC (suitename, "qof strftime", test_qof_strftime);
|
||||
GNC_TEST_ADD_FUNC (suitename, "xaccDateUtilGetStampNow", test_xaccDateUtilGetStampNow);
|
||||
GNC_TEST_ADD_FUNC (suitename, "gnc_date_timestamp", test_gnc_date_timestamp);
|
||||
GNC_TEST_ADD_FUNC (suitename, "gnc iso8601 to timespec gmt", test_gnc_iso8601_to_timespec_gmt);
|
||||
GNC_TEST_ADD_FUNC (suitename, "gnc timespec to iso8601 buff", test_gnc_timespec_to_iso8601_buff);
|
||||
GNC_TEST_ADD_FUNC (suitename, "gnc timespec2dmy", test_gnc_timespec2dmy);
|
||||
|
Loading…
Reference in New Issue
Block a user