gtranslator r3606 - trunk/src



Author: icq
Date: Mon Sep 22 09:38:51 2008
New Revision: 3606
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3606&view=rev

Log:
Added utils functions in order to get the current date, time and year.

Modified:
   trunk/src/po.c
   trunk/src/utils.c
   trunk/src/utils.h

Modified: trunk/src/po.c
==============================================================================
--- trunk/src/po.c	(original)
+++ trunk/src/po.c	Mon Sep 22 09:38:51 2008
@@ -543,10 +543,10 @@
 		   *header_comment;
 	const char *prev_translator;
 
-	time_t now;
-	struct tm *now_here;
-	char t[22];
-	gchar *year=g_malloc(5);
+	gchar *current_date;
+	gchar *current_time;
+	gchar *year;
+	gchar *new_date;
 	gchar *aux;
 
 	/*
@@ -573,14 +573,15 @@
 	/*
 	 * Update the po date 
 	 */
-	now = time(NULL);
-	now_here = localtime(&now);
-	strftime(t, 22, "%Y-%m-%d %H:%M%z", now_here);
-	strftime(year, 5, "%Y", now_here);
-	
-	aux = g_strdup (t);
-	gtranslator_header_set_po_date (header, aux);
-	g_free (aux);
+	current_date = gtranslator_utils_get_current_date ();
+	current_time = gtranslator_utils_get_current_time ();
+	year = gtranslator_utils_get_current_year ();
+
+	new_date = g_strconcat (current_date, " ", current_time, NULL);
+
+	gtranslator_header_set_po_date (header, new_date);
+
+	g_free (new_date);
 	
 	/*
          * Update the header's comment

Modified: trunk/src/utils.c
==============================================================================
--- trunk/src/utils.c	(original)
+++ trunk/src/utils.c	Mon Sep 22 09:38:51 2008
@@ -789,3 +789,42 @@
 				 "gtranslator",
 				 NULL);
 }
+
+gchar *gtranslator_utils_get_current_date (void)
+{
+  time_t now;
+  struct tm *now_here;
+  gchar *date = g_malloc (11);
+  
+  now = time(NULL);
+  now_here = localtime(&now);
+  strftime(date, 11, "%Y-%m-%d", now_here);
+
+  return date;
+}
+
+gchar *gtranslator_utils_get_current_time (void)
+{
+  time_t now;
+  struct tm *now_here;
+  gchar *t = g_malloc (11);
+
+  now = time(NULL);
+  now_here = localtime(&now);
+  strftime(t, 11, "%H:%M%z", now_here);
+ 
+  return t;
+}
+
+gchar *gtranslator_utils_get_current_year (void)
+{
+  time_t now;
+  struct tm *now_here;
+  gchar *year=g_malloc (5);
+
+  now = time(NULL);
+  now_here = localtime(&now);
+  strftime(year, 5, "%Y", now_here);
+
+  return year;
+}

Modified: trunk/src/utils.h
==============================================================================
--- trunk/src/utils.h	(original)
+++ trunk/src/utils.h	Mon Sep 22 09:38:51 2008
@@ -74,4 +74,10 @@
 						       
 gchar         *gtranslator_utils_get_user_config_dir  (void);
 
+gchar         *gtranslator_utils_get_current_date (void);
+
+gchar         *gtranslator_utils_get_current_time (void);
+
+gchar         *gtranslator_utils_get_current_year (void);
+
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]