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