plug-ins: fix failure to write IPTC TimeCreated
The IPTC TimeCreated tag does not allow fractions of a second, while Xmp.Photoshop.DateCreated (which includes the time) does allow this. In our metadata editor we base our date/time on the last value and then synchronize it with the IPTC date and time values. While doing that, we did not check if the seconds had a fractional part. To fix this we first check for the presence of a fraction by checking for a dot in the time string. Complicating factor is that a timezone difference may follow that, which we want to keep if present. So we check for that too and concatenate the parts we want.
This commit is contained in:
@ -5131,8 +5131,36 @@ metadata_editor_write_callback (GtkWidget *dialog,
|
|||||||
|
|
||||||
if (date_time_split[1] != NULL)
|
if (date_time_split[1] != NULL)
|
||||||
{
|
{
|
||||||
|
gchar **time_split = NULL;
|
||||||
|
gchar *iptc_time = NULL;
|
||||||
|
|
||||||
|
/* IPTC TimeCreated can't have fractional parts. */
|
||||||
|
time_split = g_strsplit (date_time_split[1], ".", 2);
|
||||||
|
|
||||||
|
/* A timezone adjustment can follow this, which
|
||||||
|
* we want to keep. */
|
||||||
|
if (time_split[1] != NULL)
|
||||||
|
{
|
||||||
|
gchar **tz_split = NULL;
|
||||||
|
|
||||||
|
tz_split = g_strsplit_set (time_split[1], "+-", 2);
|
||||||
|
if (tz_split[1] != NULL)
|
||||||
|
iptc_time = g_strconcat (time_split[0],
|
||||||
|
time_split[1] + strlen (tz_split[0]),
|
||||||
|
NULL);
|
||||||
|
else
|
||||||
|
iptc_time = g_strdup (time_split[0]);
|
||||||
|
g_strfreev (tz_split);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iptc_time = g_strdup (time_split[0]);
|
||||||
|
}
|
||||||
|
|
||||||
set_tag_string (g_metadata, "Iptc.Application2.TimeCreated",
|
set_tag_string (g_metadata, "Iptc.Application2.TimeCreated",
|
||||||
date_time_split[1], FALSE);
|
iptc_time, FALSE);
|
||||||
|
g_strfreev (time_split);
|
||||||
|
g_free (iptc_time);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user