From: <mar...@us...> - 2014-06-01 11:35:56
|
Revision: 14966 http://sourceforge.net/p/gphoto/code/14966 Author: marcusmeissner Date: 2014-06-01 11:35:48 +0000 (Sun, 01 Jun 2014) Log Message: ----------- fixed some subtleties in time setting, including dst Modified Paths: -------------- trunk/gphoto2/gphoto2/actions.c Modified: trunk/gphoto2/gphoto2/actions.c =================================================================== --- trunk/gphoto2/gphoto2/actions.c 2014-06-01 08:17:50 UTC (rev 14965) +++ trunk/gphoto2/gphoto2/actions.c 2014-06-01 11:35:48 UTC (rev 14966) @@ -1750,21 +1750,31 @@ break; } case GP_WIDGET_DATE: { /* int */ - int t = -1; + time_t t = -1; struct tm xtm; + memset(&xtm,0,sizeof(xtm)); + + /* We need to set UNIX time in seconds since Epoch */ + /* We get ... local time */ + if (!strcasecmp (value, "now") || !strcasecmp (value, _("now"))) t = time(NULL); #ifdef HAVE_STRPTIME - else if (strptime (value, "%c", &xtm) || strptime (value, "%Ec", &xtm)) + else if (strptime (value, "%c", &xtm) || strptime (value, "%Ec", &xtm)) { + xtm.tm_isdst = -1; t = mktime (&xtm); + } #endif if (t == -1) { - if (!sscanf (value, "%d", &t)) { + unsigned long lt; + + if (!sscanf (value, "%ld", <)) { gp_context_error (p->context, _("The passed value %s is neither a valid time nor an integer."), value); ret = GP_ERROR_BAD_PARAMETERS; break; } + t = lt; } ret = gp_widget_set_value (child, &t); if (ret != GP_OK) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |