diff --git a/src/mainwindow.c b/src/mainwindow.c index f4e1d3d..1afaca4 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -22,7 +22,7 @@ struct dateFormats { guint index_minute; } dateFormats_list[] = { { - .regex = "(\\d{1,4})-(\\d{1,2})-(\\d{1,2}) (\\d{1,2}):(\\d{1,2}).*", + .regex = "(\\d{1,4})-(\\d{1,2})-(\\d{1,2})\\s*(\\d{1,2}):(\\d{1,2}).*", .index_count = 5, .index_year = 1, .index_month = 2, @@ -30,6 +30,15 @@ struct dateFormats { .index_hour = 4, .index_minute = 5 }, +{ + .regex = "(\\d{1,2})\\.(\\d{1,2})\\.(\\d{1,4})\\s*(\\d{1,2}):(\\d{1,2}).*", + .index_count = 5, + .index_year = 3, + .index_month = 2, + .index_day = 1, + .index_hour = 4, + .index_minute = 5 +}, { .regex = "(\\d{1,4})-(\\d{1,2})-(\\d{1,2}).*", .index_count = 3, @@ -89,7 +98,7 @@ static GDateTime *mainWindow_get_date_from_string(gchar *string) day >= 1 && day <= 31 && hour >= 0 && hour <= 23 && minute >= 0 && minute <= 59) { - datetime = g_date_time_new_local(year, month, day, 0, 0, 0); + datetime = g_date_time_new_local(year, month, day, hour, minute, 0); g_regex_unref(regex); break; @@ -99,7 +108,7 @@ static GDateTime *mainWindow_get_date_from_string(gchar *string) } while ((++dateFormats)->regex); if (!datetime) - g_print("Warning! Could not match date \"%s\"!\n", string); + g_print("Warning! Could not match date in \"%s\"!\n", string); return datetime; } @@ -334,9 +343,6 @@ struct mainWindow *mainWindow_new() mainWindow_configure_treeView(mainWindow); mainWindow_connect_signals(mainWindow); - mainWindow_get_date_from_string("pointless foo"); - mainWindow_get_date_from_string("2017-02-11 12:44"); - return mainWindow; }