plug-ins: Use Glib date-time functions
This commit is contained in:
parent
4643f7898f
commit
dae02feed3
4 changed files with 45 additions and 34 deletions
|
|
@ -291,8 +291,7 @@ void
|
||||||
gimp_metadata_add_xmp_history (GimpMetadata *metadata,
|
gimp_metadata_add_xmp_history (GimpMetadata *metadata,
|
||||||
gchar *state_status)
|
gchar *state_status)
|
||||||
{
|
{
|
||||||
time_t now;
|
GDateTime *now_tm;
|
||||||
struct tm *now_tm;
|
|
||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
char timestr[256];
|
char timestr[256];
|
||||||
char tzstr[7];
|
char tzstr[7];
|
||||||
|
|
@ -442,18 +441,17 @@ gimp_metadata_add_xmp_history (GimpMetadata *metadata,
|
||||||
tags[3], id_count, history_tags[2]);
|
tags[3], id_count, history_tags[2]);
|
||||||
|
|
||||||
/* get local time */
|
/* get local time */
|
||||||
time (&now);
|
now_tm = g_date_time_new_now_local ();
|
||||||
now_tm = localtime (&now);
|
|
||||||
|
|
||||||
/* get timezone and fix format */
|
/* get timezone and fix format */
|
||||||
strftime (tzstr, 7, "%z", now_tm);
|
tmp = g_date_time_format (now_tm, "%:::z");
|
||||||
tzstr[6] = '\0';
|
g_strlcpy (tzstr, tmp, 7);
|
||||||
tzstr[5] = tzstr[4];
|
g_free (tmp);
|
||||||
tzstr[4] = tzstr[3];
|
|
||||||
tzstr[3] = ':';
|
|
||||||
|
|
||||||
/* get current time and timezone string */
|
/* get current time and timezone string */
|
||||||
strftime (timestr, 256, "%Y-%m-%dT%H:%M:%S", now_tm);
|
tmp = g_date_time_format (now_tm, "%Y-%m-%dT%H:%M:%S");
|
||||||
|
g_strlcpy (timestr, tmp, 256);
|
||||||
|
g_free (tmp);
|
||||||
tmp = g_strdup_printf ("%s%s", timestr, tzstr);
|
tmp = g_strdup_printf ("%s%s", timestr, tzstr);
|
||||||
gexiv2_metadata_try_set_tag_string (GEXIV2_METADATA (metadata),
|
gexiv2_metadata_try_set_tag_string (GEXIV2_METADATA (metadata),
|
||||||
tagstr, tmp, &error);
|
tagstr, tmp, &error);
|
||||||
|
|
@ -464,6 +462,7 @@ gimp_metadata_add_xmp_history (GimpMetadata *metadata,
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
g_date_time_unref (now_tm);
|
||||||
|
|
||||||
memset (tagstr, 0, sizeof (tagstr));
|
memset (tagstr, 0, sizeof (tagstr));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1737,8 +1737,7 @@ export_image (GFile *file,
|
||||||
guchar *pixel; /* Pixel data */
|
guchar *pixel; /* Pixel data */
|
||||||
gdouble xres, yres; /* GIMP resolution (dpi) */
|
gdouble xres, yres; /* GIMP resolution (dpi) */
|
||||||
png_time mod_time; /* Modification time (ie NOW) */
|
png_time mod_time; /* Modification time (ie NOW) */
|
||||||
time_t cutime; /* Time since epoch */
|
GDateTime *gmt; /* GMT broken down */
|
||||||
struct tm *gmt; /* GMT broken down */
|
|
||||||
gint color_type; /* PNG color type */
|
gint color_type; /* PNG color type */
|
||||||
gint bit_depth; /* Default to bit depth 16 */
|
gint bit_depth; /* Default to bit depth 16 */
|
||||||
|
|
||||||
|
|
@ -2206,16 +2205,17 @@ export_image (GFile *file,
|
||||||
|
|
||||||
if (save_time)
|
if (save_time)
|
||||||
{
|
{
|
||||||
cutime = time (NULL); /* time right NOW */
|
gmt = g_date_time_new_now_utc ();
|
||||||
gmt = gmtime (&cutime);
|
|
||||||
|
|
||||||
mod_time.year = gmt->tm_year + 1900;
|
mod_time.year = g_date_time_get_year (gmt);
|
||||||
mod_time.month = gmt->tm_mon + 1;
|
mod_time.month = g_date_time_get_month (gmt);
|
||||||
mod_time.day = gmt->tm_mday;
|
mod_time.day = g_date_time_get_day_of_month (gmt);
|
||||||
mod_time.hour = gmt->tm_hour;
|
mod_time.hour = g_date_time_get_hour (gmt);
|
||||||
mod_time.minute = gmt->tm_min;
|
mod_time.minute = g_date_time_get_minute (gmt);
|
||||||
mod_time.second = gmt->tm_sec;
|
mod_time.second = g_date_time_get_second (gmt);
|
||||||
png_set_tIME (pp, info, &mod_time);
|
png_set_tIME (pp, info, &mod_time);
|
||||||
|
|
||||||
|
g_date_time_unref (gmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PNG_iCCP_SUPPORTED)
|
#if defined(PNG_iCCP_SUPPORTED)
|
||||||
|
|
|
||||||
|
|
@ -312,22 +312,22 @@ pointer foreign_getenv(scheme *sc, pointer args)
|
||||||
|
|
||||||
pointer foreign_time(scheme *sc, pointer args)
|
pointer foreign_time(scheme *sc, pointer args)
|
||||||
{
|
{
|
||||||
time_t now;
|
GDateTime *now_tm;
|
||||||
struct tm *now_tm;
|
pointer ret;
|
||||||
pointer ret;
|
|
||||||
|
|
||||||
if (args != sc->NIL)
|
if (args != sc->NIL)
|
||||||
return sc->F;
|
return sc->F;
|
||||||
|
|
||||||
time(&now);
|
now_tm = g_date_time_new_now_local();
|
||||||
now_tm = localtime(&now);
|
|
||||||
|
|
||||||
ret = sc->vptr->cons(sc, sc->vptr->mk_integer(sc,(long) now_tm->tm_year),
|
ret = sc->vptr->cons(sc, sc->vptr->mk_integer(sc, (long) g_date_time_get_year(now_tm)),
|
||||||
sc->vptr->cons(sc, sc->vptr->mk_integer(sc,(long) now_tm->tm_mon),
|
sc->vptr->cons(sc, sc->vptr->mk_integer(sc, (long) g_date_time_get_month(now_tm)),
|
||||||
sc->vptr->cons(sc, sc->vptr->mk_integer(sc,(long) now_tm->tm_mday),
|
sc->vptr->cons(sc, sc->vptr->mk_integer(sc, (long) g_date_time_get_day_of_month(now_tm)),
|
||||||
sc->vptr->cons(sc, sc->vptr->mk_integer(sc,(long) now_tm->tm_hour),
|
sc->vptr->cons(sc, sc->vptr->mk_integer(sc, (long) g_date_time_get_hour(now_tm)),
|
||||||
sc->vptr->cons(sc, sc->vptr->mk_integer(sc,(long) now_tm->tm_min),
|
sc->vptr->cons(sc, sc->vptr->mk_integer(sc, (long) g_date_time_get_minute(now_tm)),
|
||||||
sc->vptr->cons(sc, sc->vptr->mk_integer(sc,(long) now_tm->tm_sec),sc->NIL))))));
|
sc->vptr->cons(sc, sc->vptr->mk_integer(sc, (long) g_date_time_get_second(now_tm)), sc->NIL))))));
|
||||||
|
|
||||||
|
g_date_time_unref(now_tm);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -642,6 +642,8 @@ execute_command (SFCommand *cmd)
|
||||||
gdouble total_time;
|
gdouble total_time;
|
||||||
GTimer *timer;
|
GTimer *timer;
|
||||||
gboolean is_script_error;
|
gboolean is_script_error;
|
||||||
|
GDateTime *dt;
|
||||||
|
gchar *dt_str;
|
||||||
|
|
||||||
server_log ("Processing request #%d\n", cmd->request_no);
|
server_log ("Processing request #%d\n", cmd->request_no);
|
||||||
|
|
||||||
|
|
@ -656,10 +658,14 @@ execute_command (SFCommand *cmd)
|
||||||
|
|
||||||
total_time = g_timer_elapsed (timer, NULL);
|
total_time = g_timer_elapsed (timer, NULL);
|
||||||
time (&clocknow);
|
time (&clocknow);
|
||||||
|
dt = g_date_time_new_from_unix_local (clocknow);
|
||||||
|
dt_str = g_date_time_format (dt, "%c");
|
||||||
server_log ("Request #%d processed in %.3f seconds, finishing on %s",
|
server_log ("Request #%d processed in %.3f seconds, finishing on %s",
|
||||||
cmd->request_no, total_time, ctime (&clocknow));
|
cmd->request_no, total_time, dt_str);
|
||||||
|
|
||||||
g_timer_destroy (timer);
|
g_timer_destroy (timer);
|
||||||
|
g_free (dt_str);
|
||||||
|
g_date_time_unref (dt);
|
||||||
|
|
||||||
buffer[MAGIC_BYTE] = MAGIC;
|
buffer[MAGIC_BYTE] = MAGIC;
|
||||||
buffer[ERROR_BYTE] = is_script_error ? TRUE : FALSE;
|
buffer[ERROR_BYTE] = is_script_error ? TRUE : FALSE;
|
||||||
|
|
@ -702,6 +708,8 @@ read_from_client (gint filedes)
|
||||||
gint command_len;
|
gint command_len;
|
||||||
gint nbytes;
|
gint nbytes;
|
||||||
gint i;
|
gint i;
|
||||||
|
GDateTime *dt;
|
||||||
|
gchar *dt_str;
|
||||||
|
|
||||||
for (i = 0; i < COMMAND_HEADER;)
|
for (i = 0; i < COMMAND_HEADER;)
|
||||||
{
|
{
|
||||||
|
|
@ -765,14 +773,18 @@ read_from_client (gint filedes)
|
||||||
/* Get the client address from the address/socket table */
|
/* Get the client address from the address/socket table */
|
||||||
clientaddr = g_hash_table_lookup (clients, GINT_TO_POINTER (cmd->filedes));
|
clientaddr = g_hash_table_lookup (clients, GINT_TO_POINTER (cmd->filedes));
|
||||||
time (&clock);
|
time (&clock);
|
||||||
/* ! ctime has trailing newline so put it last. */
|
dt = g_date_time_new_from_unix_local (clock);
|
||||||
|
dt_str = g_date_time_format (dt, "%c");
|
||||||
server_log ("received request #%d from IP address %s: %s,"
|
server_log ("received request #%d from IP address %s: %s,"
|
||||||
"[queue length: %d] on %s",
|
"[queue length: %d] on %s",
|
||||||
cmd->request_no,
|
cmd->request_no,
|
||||||
clientaddr ? clientaddr : "<invalid>",
|
clientaddr ? clientaddr : "<invalid>",
|
||||||
cmd->command,
|
cmd->command,
|
||||||
queue_length,
|
queue_length,
|
||||||
ctime (&clock));
|
dt_str);
|
||||||
|
|
||||||
|
g_free (dt_str);
|
||||||
|
g_date_time_unref (dt);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue