--- app_voicemail.c.orig 2005-03-02 23:24:02.000000000 +0100 +++ app_voicemail.c 2005-06-18 03:35:28.000000000 +0200 @@ -277,6 +277,8 @@ static char *emailsubject = NULL; static char fromstring[100]; static char pagerfromstring[100]; +static int emaildateformat; + static char emailtitle[100]; static char charset[32] = "ISO-8859-1"; @@ -869,6 +871,7 @@ char dur[256]; char tmp[80] = "/tmp/astmail-XXXXXX"; char tmp2[256]; + time_t t; struct tm tm; struct vm_zone *the_zone = NULL; @@ -920,6 +923,22 @@ strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S %z", &tm); fprintf(p, "Date: %s\n", date); + /* Set 12 or 24 hour time format on outgoing voicemail mail */ + if (emaildateformat) { + switch (emaildateformat) { + case 12: + strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm); + break; + + case 24: + strftime(date, sizeof(date), "%A, %d %B %Y at %H:%M:%S", &tm); + break; + } + } + else { + strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm); /* Fall back to 12 hours format if not in config file */ + } + if (*fromstring) { struct ast_channel *ast = ast_channel_alloc(0); if (ast) { @@ -936,7 +955,6 @@ } else fprintf(p, "From: Asterisk PBX <%s>\n", who); fprintf(p, "To: %s <%s>\n", vmu->fullname, vmu->email); - if (emailsubject) { struct ast_channel *ast = ast_channel_alloc(0); if (ast) { @@ -972,7 +990,7 @@ fprintf(p, "--%s\n", bound); } fprintf(p, "Content-Type: text/plain; charset=%s\nContent-Transfer-Encoding: 8bit\n\n", charset); - strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm); + if (emailbody) { struct ast_channel *ast = ast_channel_alloc(0); if (ast) { @@ -3977,6 +3995,7 @@ char *callbackcxt = NULL; char *exitcxt = NULL; char *extpc; + char *dateformatstr; int x; int tmpadsi[4]; @@ -4003,6 +4022,21 @@ if (cfg) { /* General settings */ + /* Check for 12 or 24 hour date format in voicemail mail */ + if ((dateformatstr = ast_variable_retrieve(cfg, "general", "emaildateformat"))) { + emaildateformat = atoi(dateformatstr); + switch(emaildateformat) { + case 12: + case 24: + emaildateformat = atoi(dateformatstr); + break; + + default: + ast_log(LOG_WARNING, "Invalid emaildateformat: %d set in config. Falling back to 12 hour format.\n", emaildateformat); + emaildateformat = 12; // fall back to 12 hours format + } + } + /* Attach voice message to mail message ? */ attach_voicemail = 1; if (!(astattach = ast_variable_retrieve(cfg, "general", "attach"))) @@ -4271,7 +4305,7 @@ if ((s=ast_variable_retrieve(cfg, "general", "fromstring"))) strncpy(fromstring,s,sizeof(fromstring)-1); if ((s=ast_variable_retrieve(cfg, "general", "pagerfromstring"))) - strncpy(pagerfromstring,s,sizeof(pagerfromstring)-1); + strncpy(pagerfromstring,s,sizeof(pagerfromstring)-1); if ((s=ast_variable_retrieve(cfg, "general", "charset"))) strncpy(charset,s,sizeof(charset)-1); if ((s=ast_variable_retrieve(cfg, "general", "adsifdn"))) {