/soc/2015/igor.gajowiak/chatlog: 4d5e7685a967: Fixed date parsin...

Igor Gajowiak <[email protected]>
Newsgroups gmane.comp.gnome.gaim.cvs
Message-ID <[email protected]>
Changeset: 4d5e7685a9670c24f902b19e24bf8ed638d0933c
Author:	 Igor Gajowiak <[email protected]>
Date:	 2015-08-17 23:52 +0200
Branch:	 default
URL: https://hg.pidgin.im/soc/2015/igor.gajowiak/chatlog/rev/4d5e7685a967

Description:

Fixed date parsing in the legacy log.

diffstat:

 libpurple/plugins/log/legacylog.c |  24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diffs (48 lines):

diff --git a/libpurple/plugins/log/legacylog.c b/libpurple/plugins/log/legacylog.c
--- a/libpurple/plugins/log/legacylog.c
+++ b/libpurple/plugins/log/legacylog.c
@@ -336,16 +336,29 @@ parse_timestamp(const gchar *date, const
 		return FALSE;
 	}
 
+	/* If there is a date in time string then probably day changed */
 	g_match_info_fetch_pos(info, 1, &begin, &end);
+	if (begin != -1) {
+		g_match_info_fetch_pos(info, 2, &begin, &end);
+		month = g_ascii_strtoull(&date[begin], NULL, 10);
+
+		g_match_info_fetch_pos(info, 3, &begin, &end);
+		day = g_ascii_strtoull(&date[begin], NULL, 10);
+
+		g_match_info_fetch_pos(info, 4, &begin, &end);
+		year = g_ascii_strtoull(&date[begin], NULL, 10);
+	}
+
+	g_match_info_fetch_pos(info, 5, &begin, &end);
 	guint64 hour = g_ascii_strtoull(&time[begin], NULL, 10);
 
-	g_match_info_fetch_pos(info, 2, &begin, &end);
+	g_match_info_fetch_pos(info, 6, &begin, &end);
 	guint64 min = g_ascii_strtoull(&time[begin], NULL, 10);
 
-	g_match_info_fetch_pos(info, 3, &begin, &end);
+	g_match_info_fetch_pos(info, 7, &begin, &end);
 	guint64 sec = g_ascii_strtoull(&time[begin], NULL, 10);
 
-	g_match_info_fetch_pos(info, 4, &begin, &end);
+	g_match_info_fetch_pos(info, 8, &begin, &end);
 	if (g_strcmp0(&time[begin], "PM") == 0)
 		hour += 12;
 	
@@ -710,8 +723,9 @@ plugin_load(PurplePlugin *plugin, GError
 	date_regex = g_regex_new("^([\\d]{4})-([\\d]{2})-([\\d]{2})\\.",0, 0, NULL);
 	g_assert(date_regex);
 
-	time_regex = g_regex_new("^([\\d]{2}):([\\d]{2}):([\\d]{2}) (AM|PM)",
-		0, 0, NULL);
+	time_regex = g_regex_new(
+		"^(([\\d]{2})/([\\d]{2})/([\\d]{4}) )?([\\d]{2}):([\\d]{2}):([\\d]{2}) "
+		"(AM|PM)", 0, 0, NULL);
 	g_assert(time_regex);
 
 	contact_regex = g_regex_new("^(.*)\\.chat$", 0, 0, NULL);

_______________________________________________
Commits mailing list
[email protected]
https://pidgin.im/cgi-bin/mailman/listinfo/commits
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.