]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3038
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 7 Feb 2011 19:14:20 +0000 (13:14 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 7 Feb 2011 19:14:20 +0000 (13:14 -0600)
src/mod/applications/mod_commands/mod_commands.c

index 807770ac159d49883cc322637a15cf5b8f4d7695..f34042a54fd1e39e9c67eef167ac722118f3ea42 100644 (file)
@@ -4439,19 +4439,23 @@ SWITCH_STANDARD_API(strftime_tz_api_function)
 
                if ((format = strchr(mycmd, ' '))) {
                        *format++ = '\0';
-               }
                
-               if ((p = strchr(format, '|'))) {
-                       *p++ = '\0';
-                       when = atol(format);
-                       format = p;
+                       if (format && (p = strchr(format, '|'))) {
+                               *p++ = '\0';
+                               when = atol(format);
+                               format = p;
+                       }
                }
        }
 
-       if (switch_strftime_tz(tz_name, format, date, sizeof(date), when * 1000000) == SWITCH_STATUS_SUCCESS) { /* The lookup of the zone may fail. */
+       if (zstr(format)) {
+               format = "%Y-%m-%d";
+       }
+       
+       if (format && switch_strftime_tz(tz_name, format, date, sizeof(date), when * 1000000) == SWITCH_STATUS_SUCCESS) {       /* The lookup of the zone may fail. */
                stream->write_function(stream, "%s", date);
        } else {
-               stream->write_function(stream, "-ERR Invalid Timezone\n");
+               stream->write_function(stream, "-ERR Invalid Timezone/Format\n");
        }
 
        switch_safe_free(mycmd);