Commit 3f1b4790 authored by Benedikt Meurer's avatar Benedikt Meurer

2007-11-28 Benedikt Meurer <benny@xfce.org>

	* plugins/thunar-sbr/: Import new date renamer based on patch
	  from Nick Schermer <nick@xfce.org>. Bug #3656.
	* docs/manual/: Update the user manual.
	* po/POTFILES.in: Add new file here.
	* po/Thunar.pot, po/*.po: Merge new strings.
	* po/de.po: Update german translations.
	* po-doc/Thunar.pot, po-doc/*.po: Merge new strings.




(Old svn revision: 26394)
parent 3f21997a
2007-11-28 Benedikt Meurer <benny@xfce.org>
* plugins/thunar-sbr/: Import new date renamer based on patch
from Nick Schermer <nick@xfce.org>. Bug #3656.
* docs/manual/: Update the user manual.
* po/POTFILES.in: Add new file here.
* po/Thunar.pot, po/*.po: Merge new strings.
* po/de.po: Update german translations.
* po-doc/Thunar.pot, po-doc/*.po: Merge new strings.
2007-11-28 Benedikt Meurer <benny@xfce.org>
* thunar-vfs/thunar-vfs-exec.c(thunar_vfs_exec_on_screen):
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY date "January 2007">
<!ENTITY date "November 2007">
<!ENTITY version "@PACKAGE_VERSION@">
<!ENTITY application "@PACKAGE_NAME@">
]>
......@@ -1289,6 +1289,7 @@ $ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbna
<itemizedlist>
<listitem><para>Remove characters.</para></listitem>
<listitem><para>Numbering files.</para></listitem>
<listitem><para>Insert Date or Time.</para></listitem>
<listitem><para>Insert or overwrite characters.</para></listitem>
<listitem><para>Search and replace characters.</para></listitem>
<listitem><para>Convert to uppercase, lowercase or camlcase.</para></listitem>
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY date "January 2007">
<!ENTITY date "November 2007">
<!ENTITY version "@PACKAGE_VERSION@">
<!ENTITY application "@PACKAGE_NAME@">
]>
......@@ -1273,6 +1273,7 @@ $ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbna
<itemizedlist>
<listitem><para>Remove characters.</para></listitem>
<listitem><para>Numbering files.</para></listitem>
<listitem><para>Insert Date or Time.</para></listitem>
<listitem><para>Insert or overwrite characters.</para></listitem>
<listitem><para>Search and replace characters.</para></listitem>
<listitem><para>Convert to uppercase, lowercase or camlcase.</para></listitem>
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY date "January 2007">
<!ENTITY date "November 2007">
<!ENTITY version "@PACKAGE_VERSION@">
<!ENTITY application "@PACKAGE_NAME@">
]>
......@@ -1263,6 +1263,7 @@ $ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbna
<itemizedlist>
<listitem><para>Remove characters.</para></listitem>
<listitem><para>Numbering files.</para></listitem>
<listitem><para>Insert Date or Time.</para></listitem>
<listitem><para>Insert or overwrite characters.</para></listitem>
<listitem><para>Search and replace characters.</para></listitem>
<listitem><para>Convert to uppercase, lowercase or camlcase.</para></listitem>
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY date "January 2007">
<!ENTITY date "November 2007">
<!ENTITY version "@PACKAGE_VERSION@">
<!ENTITY application "@PACKAGE_NAME@">
]>
......@@ -797,6 +797,7 @@ $ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbna
<itemizedlist>
<listitem><para>Supprimer des caractères.</para></listitem>
<listitem><para>Numéroter les fichiers.</para></listitem>
<listitem><para>Insert Date or Time.</para></listitem>
<listitem><para>Insérer ou écraser des caractères.</para></listitem>
<listitem><para>Chercher et remplacer des caractères.</para></listitem>
<listitem><para>Convertir en majuscule, minuscule ou 1ère LettreEnMajuscule (CamelCase)</para></listitem>
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY date "January 2007">
<!ENTITY date "November 2007">
<!ENTITY version "@PACKAGE_VERSION@">
<!ENTITY application "@PACKAGE_NAME@">
]>
......@@ -1263,6 +1263,7 @@ $ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbna
<itemizedlist>
<listitem><para>Remove characters.</para></listitem>
<listitem><para>Numbering files.</para></listitem>
<listitem><para>Insert Date or Time.</para></listitem>
<listitem><para>Insert or overwrite characters.</para></listitem>
<listitem><para>Search and replace characters.</para></listitem>
<listitem><para>Convert to uppercase, lowercase or camlcase.</para></listitem>
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY date "January 2007">
<!ENTITY date "November 2007">
<!ENTITY version "@PACKAGE_VERSION@">
<!ENTITY application "@PACKAGE_NAME@">
]>
......@@ -1278,6 +1278,7 @@ $ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbna
<itemizedlist>
<listitem><para>Remove characters.</para></listitem>
<listitem><para>Numbering files.</para></listitem>
<listitem><para>Insert Date or Time.</para></listitem>
<listitem><para>Insert or overwrite characters.</para></listitem>
<listitem><para>Search and replace characters.</para></listitem>
<listitem><para>Convert to uppercase, lowercase or camlcase.</para></listitem>
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY date "January 2007">
<!ENTITY date "November 2007">
<!ENTITY version "@PACKAGE_VERSION@">
<!ENTITY application "@PACKAGE_NAME@">
]>
......@@ -803,6 +803,7 @@ $ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbna
<itemizedlist>
<listitem><para>usuwanie znaków,</para></listitem>
<listitem><para>numerowanie plików,</para></listitem>
<listitem><para>Insert Date or Time.</para></listitem>
<listitem><para>wstawianie lub usuwanie znaków,</para></listitem>
<listitem><para>znajdowanie i zamienianie znaków,</para></listitem>
<listitem><para>zmiana sposobu stosowania wielkich i małych liter.</para></listitem>
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY date "January 2007">
<!ENTITY date "November 2007">
<!ENTITY version "@PACKAGE_VERSION@">
<!ENTITY application "@PACKAGE_NAME@">
]>
......@@ -1263,6 +1263,7 @@ $ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbna
<itemizedlist>
<listitem><para>Remove characters.</para></listitem>
<listitem><para>Numbering files.</para></listitem>
<listitem><para>Insert Date or Time.</para></listitem>
<listitem><para>Insert or overwrite characters.</para></listitem>
<listitem><para>Search and replace characters.</para></listitem>
<listitem><para>Convert to uppercase, lowercase or camlcase.</para></listitem>
......
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
<!ENTITY date "January 2007">
<!ENTITY date "November 2007">
<!ENTITY version "@PACKAGE_VERSION@">
<!ENTITY application "@PACKAGE_NAME@">
]>
......@@ -1263,6 +1263,7 @@ $ sudo install eps-thumbnailer.desktop /usr/local/share/thumbnailers/eps-thumbna
<itemizedlist>
<listitem><para>Remove characters.</para></listitem>
<listitem><para>Numbering files.</para></listitem>
<listitem><para>Insert Date or Time.</para></listitem>
<listitem><para>Insert or overwrite characters.</para></listitem>
<listitem><para>Search and replace characters.</para></listitem>
<listitem><para>Convert to uppercase, lowercase or camlcase.</para></listitem>
......
......@@ -15,6 +15,8 @@ extensions_LTLIBRARIES = \
thunar_sbr_la_SOURCES = \
thunar-sbr-case-renamer.c \
thunar-sbr-case-renamer.h \
thunar-sbr-date-renamer.c \
thunar-sbr-date-renamer.h \
thunar-sbr-enum-types.c \
thunar-sbr-enum-types.h \
thunar-sbr-insert-renamer.c \
......@@ -30,6 +32,7 @@ thunar_sbr_la_SOURCES = \
thunar-sbr-replace-renamer.h
thunar_sbr_la_CFLAGS = \
$(EXIF_CFLAGS) \
$(EXO_CFLAGS) \
$(PCRE_CFLAGS) \
$(PLATFORM_CFLAGS)
......@@ -41,7 +44,8 @@ thunar_sbr_la_LDFLAGS = \
$(PLATFORM_LDFLAGS)
thunar_sbr_la_LIBADD = \
$(PCRE_LIBS)
$(PCRE_LIBS) \
$(EXIF_LIBS)
EXTRA_DIST = \
README
......
......@@ -5,6 +5,7 @@ Thunar-sbr is an extension to Thunar, which includes a bunch of simple renamers
for the bulk rename dialog:
* Insert / Overwrite
* Insert Date / Time
* Numbering
* Remove Characters
* Search & Replace
......
/* $Id$ */
/*-
* Copyright (c) 2007 Nick Schermer <nick@xfce.org>
* Copyright (c) 2007 Benedikt Meurer <benny@xfce.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_TIME_H
#include <time.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#include <exo/exo.h>
#include <thunar-sbr/thunar-sbr-date-renamer.h>
#include <thunar-vfs/thunar-vfs.h>
#ifdef HAVE_EXIF
#include <libexif/exif-data.h>
#endif
/* Property identifiers */
enum
{
PROP_0,
PROP_MODE,
PROP_FORMAT,
PROP_OFFSET,
PROP_OFFSET_MODE,
};
static void thunar_sbr_date_renamer_class_init (ThunarSbrDateRenamerClass *klass);
static void thunar_sbr_date_renamer_init (ThunarSbrDateRenamer *date_renamer);
static void thunar_sbr_date_renamer_finalize (GObject *object);
static void thunar_sbr_date_renamer_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void thunar_sbr_date_renamer_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static gchar *thunar_sbr_get_time_string (ThunarVfsFileTime file_time,
const gchar *custom_format);
#ifdef HAVE_EXIF
static ThunarVfsFileTime thunar_sbr_get_time_from_string (const gchar *string);
#endif
static ThunarVfsFileTime thunar_sbr_get_time (ThunarxFileInfo *file,
ThunarSbrDateMode mode);
static gchar *thunar_sbr_date_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
guint index);
struct _ThunarSbrDateRenamerClass
{
ThunarxRenamerClass __parent__;
};
struct _ThunarSbrDateRenamer
{
ThunarxRenamer __parent__;
GtkTooltips *tooltips;
ThunarSbrDateMode mode;
guint offset;
ThunarSbrOffsetMode offset_mode;
gchar *format;
};
THUNARX_DEFINE_TYPE (ThunarSbrDateRenamer, thunar_sbr_date_renamer, THUNARX_TYPE_RENAMER);
static void
thunar_sbr_date_renamer_class_init (ThunarSbrDateRenamerClass *klass)
{
ThunarxRenamerClass *thunarxrenamer_class;
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = thunar_sbr_date_renamer_finalize;
gobject_class->get_property = thunar_sbr_date_renamer_get_property;
gobject_class->set_property = thunar_sbr_date_renamer_set_property;
thunarxrenamer_class = THUNARX_RENAMER_CLASS (klass);
thunarxrenamer_class->process = thunar_sbr_date_renamer_process;
/**
* ThunarSbrDateRenamer:mode:
*
* The #ThunarSbrDateMode to use.
**/
g_object_class_install_property (gobject_class,
PROP_MODE,
g_param_spec_enum ("mode",
"mode",
"mode",
THUNAR_SBR_TYPE_DATE_MODE,
THUNAR_SBR_DATE_MODE_NOW,
G_PARAM_READWRITE));
/**
* ThunarSbrDateRenamer:format:
*
* The date format to insert.
**/
g_object_class_install_property (gobject_class,
PROP_FORMAT,
g_param_spec_string ("format",
"format",
"format",
"%Y%m%d",
G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
/**
* ThunarSbrDateRenamer:offset:
*
* The starting offset at which to insert/overwrite.
**/
g_object_class_install_property (gobject_class,
PROP_OFFSET,
g_param_spec_uint ("offset",
"offset",
"offset",
0, G_MAXUINT, 0,
G_PARAM_READWRITE));
/**
* ThunarSbrDateRenamer:offset-mode:
*
* The offset mode for the renamer.
**/
g_object_class_install_property (gobject_class,
PROP_OFFSET_MODE,
g_param_spec_enum ("offset-mode",
"offset-mode",
"offset-mode",
THUNAR_SBR_TYPE_OFFSET_MODE,
THUNAR_SBR_OFFSET_MODE_LEFT,
G_PARAM_READWRITE));
}
static void
thunar_sbr_date_renamer_init (ThunarSbrDateRenamer *date_renamer)
{
GEnumClass *klass;
AtkRelationSet *relations;
AtkRelation *relation;
AtkObject *object;
GtkWidget *vbox, *hbox;
GtkWidget *label, *combo;
GtkWidget *spinner;
GtkWidget *entry;
GtkAdjustment *adjustment;
gint n;
/* allocate tooltips for the renamer */
date_renamer->tooltips = gtk_tooltips_new ();
exo_gtk_object_ref_sink (GTK_OBJECT (date_renamer->tooltips));
vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (date_renamer), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new_with_mnemonic (_("Insert _time:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
combo = gtk_combo_box_new_text ();
klass = g_type_class_ref (THUNAR_SBR_TYPE_DATE_MODE);
for (n = 0; n < klass->n_values; ++n)
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _(klass->values[n].value_nick));
exo_mutual_binding_new (G_OBJECT (date_renamer), "mode", G_OBJECT (combo), "active");
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
g_type_class_unref (klass);
gtk_widget_show (combo);
/* set Atk label relation for the combo */
object = gtk_widget_get_accessible (combo);
relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
atk_relation_set_add (relations, relation);
g_object_unref (G_OBJECT (relation));
label = gtk_label_new_with_mnemonic (_("_Format:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
entry = gtk_entry_new ();
exo_mutual_binding_new (G_OBJECT (entry), "text", G_OBJECT (date_renamer), "format");
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
gtk_tooltips_set_tip (date_renamer->tooltips, entry,
_("The format describes the date and time parts to insert "
"into the file name. For example, %Y will be substituted "
"with the year, %m with the month and %d with the day. "
"See the documentation of the date utility for additional "
"information."), NULL);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
gtk_widget_show (entry);
/* set Atk label relation for the entry */
object = gtk_widget_get_accessible (entry);
relations = atk_object_ref_relation_set (gtk_widget_get_accessible (label));
relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
atk_relation_set_add (relations, relation);
g_object_unref (G_OBJECT (relation));
hbox = gtk_hbox_new (FALSE, 12);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new_with_mnemonic (_("_At position:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
spinner = gtk_spin_button_new_with_range (0u, G_MAXUINT, 1u);
gtk_entry_set_width_chars (GTK_ENTRY (spinner), 4);
gtk_entry_set_alignment (GTK_ENTRY (spinner), 1.0f);
gtk_entry_set_activates_default (GTK_ENTRY (spinner), TRUE);
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinner), 0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinner), TRUE);
gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (spinner), TRUE);
gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), spinner);
gtk_widget_show (spinner);
adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spinner));
exo_mutual_binding_new (G_OBJECT (date_renamer), "offset", G_OBJECT (adjustment), "value");
combo = gtk_combo_box_new_text ();
klass = g_type_class_ref (THUNAR_SBR_TYPE_OFFSET_MODE);
for (n = 0; n < klass->n_values; ++n)
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _(klass->values[n].value_nick));
exo_mutual_binding_new (G_OBJECT (date_renamer), "offset-mode", G_OBJECT (combo), "active");
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
g_type_class_unref (klass);
gtk_widget_show (combo);
}
static void
thunar_sbr_date_renamer_finalize (GObject *object)
{
ThunarSbrDateRenamer *date_renamer = THUNAR_SBR_DATE_RENAMER (object);
/* release the tooltips */
g_object_unref (G_OBJECT (date_renamer->tooltips));
/* release the format */
g_free (date_renamer->format);
(*G_OBJECT_CLASS (thunar_sbr_date_renamer_parent_class)->finalize) (object);
}
static void
thunar_sbr_date_renamer_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ThunarSbrDateRenamer *date_renamer = THUNAR_SBR_DATE_RENAMER (object);
switch (prop_id)
{
case PROP_MODE:
g_value_set_enum (value, thunar_sbr_date_renamer_get_mode (date_renamer));
break;
case PROP_FORMAT:
g_value_set_string (value, thunar_sbr_date_renamer_get_format (date_renamer));
break;
case PROP_OFFSET:
g_value_set_uint (value, thunar_sbr_date_renamer_get_offset (date_renamer));
break;
case PROP_OFFSET_MODE:
g_value_set_enum (value, thunar_sbr_date_renamer_get_offset_mode (date_renamer));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
thunar_sbr_date_renamer_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ThunarSbrDateRenamer *date_renamer = THUNAR_SBR_DATE_RENAMER (object);
switch (prop_id)
{
case PROP_MODE:
thunar_sbr_date_renamer_set_mode (date_renamer, g_value_get_enum (value));
break;
case PROP_FORMAT:
thunar_sbr_date_renamer_set_format (date_renamer, g_value_get_string (value));
break;
case PROP_OFFSET:
thunar_sbr_date_renamer_set_offset (date_renamer, g_value_get_uint (value));
break;
case PROP_OFFSET_MODE:
thunar_sbr_date_renamer_set_offset_mode (date_renamer, g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gchar *
thunar_sbr_get_time_string (ThunarVfsFileTime file_time,
const gchar *format)
{
struct tm *tm;
gchar *converted;
gchar buffer[1024];
gint length;
/* determine the local file time */
tm = localtime (&file_time);
/* conver the format to the current locale */
converted = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
/* parse the format */
length = strftime (buffer, sizeof (buffer), converted, tm);
/* cleanup */
g_free (converted);
/* check if strftime succeeded */
if (G_UNLIKELY (length == 0))
return NULL;
/* return the utf-8 string */
return g_locale_to_utf8 (buffer, -1, NULL, NULL, NULL);
}
#ifdef HAVE_EXIF
static ThunarVfsFileTime
thunar_sbr_get_time_from_string (const gchar *string)
{
struct tm tm;
#ifdef HAVE_STRPTIME
/* parse the string with strptime */
strptime (string, "%Y:%m:%d %T", &tm);
#else
gint result;
gint year, month, day, hour, min, sec;
result = sscanf (string, "%d:%d:%d %d:%d:%d", &year, &month, &day, &hour, &min, &sec);
/* only continue when atleast the date is parsed succesfully */
if (G_LIKELY (result >= 3 && g_date_valid_dmy (day, month, year)))
{
/* be sure to start with a clean tm */
memset (&tm, 0, sizeof (tm));
/* set the date */
tm.tm_year = year - 1900;
tm.tm_mon = month - 1;
tm.tm_mday = day;
/* set the time */
tm.tm_hour = result >= 4? hour : 0;
tm.tm_min = result >= 5 ? min : 0;