Revision: 2040 http://geany.svn.sourceforge.net/geany/?rev=2040&view=rev Author: eht16 Date: 2007-11-11 01:03:01 -0800 (Sun, 11 Nov 2007)
Log Message: ----------- Remove utils_get_date() and add format argument to utils_get_date_time().
Modified Paths: -------------- trunk/src/templates.c trunk/src/utils.c trunk/src/utils.h
Modified: trunk/src/templates.c =================================================================== --- trunk/src/templates.c 2007-11-08 16:58:20 UTC (rev 2039) +++ trunk/src/templates.c 2007-11-11 09:03:01 UTC (rev 2040) @@ -40,6 +40,9 @@ #include "ui_utils.h"
+#define TEMPLATE_DATE_FORMAT "%Y-%m-%d" +#define TEMPLATE_DATETIME_FORMAT "%d.%m.%Y %H:%M:%S %Z" + // default templates, only for initial tempate file creation on first start of Geany static const gchar templates_gpl_notice[] = "\ This program is free software; you can redistribute it and/or modify\n\ @@ -347,13 +350,9 @@
void templates_init(void) { - time_t tp = time(NULL); - const struct tm *tm = localtime(&tp); - gchar *year = g_malloc0(5); - gchar *date = utils_get_date(); + gchar *year = utils_get_date_time("%Y"); + gchar *date = utils_get_date_time(TEMPLATE_DATE_FORMAT);
- strftime(year, 5, "%Y", tm); - init_general_templates(year, date); init_ft_templates(year, date); create_new_menu_items(); @@ -524,12 +523,12 @@ gchar *template = g_strdup(templates[GEANY_TEMPLATE_FILEHEADER]); gchar *shortname; gchar *result; - gchar *date = utils_get_date_time(); + gchar *date = utils_get_date_time(TEMPLATE_DATETIME_FORMAT); filetype_id ft_id = filetype_idx; filetype *ft = filetypes[ft_id];
filetypes_load_config(ft_id); // load any user extension setting - + if (fname == NULL) { if (ft_id == GEANY_FILETYPES_ALL) @@ -587,8 +586,8 @@ gchar *templates_get_template_function(gint filetype_idx, const gchar *func_name) { gchar *template = g_strdup(templates[GEANY_TEMPLATE_FUNCTION]); - gchar *date = utils_get_date(); - gchar *datetime = utils_get_date_time(); + gchar *date = utils_get_date_time(TEMPLATE_DATE_FORMAT); + gchar *datetime = utils_get_date_time(TEMPLATE_DATETIME_FORMAT); gchar *result;
template = utils_str_replace(template, "{date}", date); @@ -606,7 +605,7 @@
gchar *templates_get_template_changelog(void) { - gchar *date = utils_get_date_time(); + gchar *date = utils_get_date_time(TEMPLATE_DATETIME_FORMAT); gchar *result = g_strdup(templates[GEANY_TEMPLATE_CHANGELOG]); result = utils_str_replace(result, "{date}", date);
Modified: trunk/src/utils.c =================================================================== --- trunk/src/utils.c 2007-11-08 16:58:20 UTC (rev 2039) +++ trunk/src/utils.c 2007-11-11 09:03:01 UTC (rev 2040) @@ -881,24 +881,16 @@ }
-gchar *utils_get_date_time() +gchar *utils_get_date_time(const gchar *format) { time_t tp = time(NULL); const struct tm *tm = localtime(&tp); - gchar *date = g_malloc0(25); + gchar *date = g_malloc0(256);
- strftime(date, 25, "%d.%m.%Y %H:%M:%S %Z", tm); - return date; -} + if (format == NULL) + return NULL;
- -gchar *utils_get_date() -{ - time_t tp = time(NULL); - const struct tm *tm = localtime(&tp); - gchar *date = g_malloc0(11); - - strftime(date, 11, "%Y-%m-%d", tm); + strftime(date, 256, format, tm); return date; }
Modified: trunk/src/utils.h =================================================================== --- trunk/src/utils.h 2007-11-08 16:58:20 UTC (rev 2039) +++ trunk/src/utils.h 2007-11-11 09:03:01 UTC (rev 2040) @@ -99,10 +99,8 @@ gint utils_strpos(const gchar* haystack, const gchar * needle);
-gchar *utils_get_date_time(); +gchar *utils_get_date_time(const gchar *format);
-gchar *utils_get_date(); - gchar *utils_get_initials(gchar *name);
gboolean utils_get_setting_boolean(GKeyFile *config, const gchar *section, const gchar *key, const gboolean default_value);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.