diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-15 00:24:24 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-02-15 00:24:24 +0000 |
commit | 15db46a445a4d6d71993475369b4a4906861f362 (patch) | |
tree | 6572dc8ac1336a5e0c0859186138a5313e88bd85 /apps | |
parent | 69f7e69869d726709046bffd71fd109b7dc4560d (diff) |
add API function for parsing strings to time_t (issue #6320, with mods)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@10105 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_sayunixtime.c | 47 | ||||
-rw-r--r-- | apps/app_voicemail.c | 8 |
2 files changed, 16 insertions, 39 deletions
diff --git a/apps/app_sayunixtime.c b/apps/app_sayunixtime.c index c6db4f140..ad96c6d6f 100644 --- a/apps/app_sayunixtime.c +++ b/apps/app_sayunixtime.c @@ -76,45 +76,26 @@ static int sayunixtime_exec(struct ast_channel *chan, void *data) struct localuser *u; char *s,*zone=NULL,*timec,*format; time_t unixtime; - struct timeval tv; + s = ast_strdupa(data); + if (!s) + return data ? -1 : 0; LOCAL_USER_ADD(u); - tv = ast_tvnow(); - unixtime = (time_t)tv.tv_sec; - - if( !strcasecmp(chan->language, "da" ) ) { - format = "A dBY HMS"; - } else if ( !strcasecmp(chan->language, "de" ) ) { - format = "A dBY HMS"; - } else { - format = "ABdY 'digits/at' IMp"; - } - - if (data) { - s = data; - if ((s = ast_strdupa(s))) { - timec = strsep(&s,"|"); - if ((timec) && (*timec != '\0')) { - long timein; - if (sscanf(timec,"%ld",&timein) == 1) { - unixtime = (time_t)timein; - } - } - if (s) { - zone = strsep(&s,"|"); - if (zone && (*zone == '\0')) - zone = NULL; - if (s) { - format = s; - } - } - } + format = "c"; /* default datetime */ + + timec = strsep(&s,"|"); + ast_get_time_t(timec, &unixtime, time(NULL)); + if (s) { + zone = strsep(&s,"|"); + if (ast_strlen_zero(zone)) + zone = NULL; } + if (s) /* override format */ + format = s; - if (chan->_state != AST_STATE_UP) { + if (chan->_state != AST_STATE_UP) res = ast_answer(chan); - } if (!res) res = ast_say_date_with_format(chan, unixtime, AST_DIGIT_ANY, chan->language, format, zone); diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index da3f90c0e..13ad2f786 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -3608,25 +3608,21 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v int res = 0; struct vm_zone *the_zone = NULL; time_t t; - long tin; - if (sscanf(origtime,"%ld",&tin) < 1) { + if (ast_get_time_t(origtime, &t, 0)) { ast_log(LOG_WARNING, "Couldn't find origtime in %s\n", filename); return 0; } - t = tin; /* Does this user have a timezone specified? */ if (!ast_strlen_zero(vmu->zonetag)) { /* Find the zone in the list */ struct vm_zone *z; - z = zones; - while (z) { + for (z = zones; z; z = z->next) { if (!strcmp(z->name, vmu->zonetag)) { the_zone = z; break; } - z = z->next; } } |