get rid of Months.
authorPierre Habouzit <madcoder@debian.org>
Thu, 16 Aug 2007 08:12:11 +0000 (10:12 +0200)
committerPierre Habouzit <madcoder@debian.org>
Thu, 16 Aug 2007 08:12:11 +0000 (10:12 +0200)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
globals.h
nntp.c

index 301f9ac..43c7d81 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -154,12 +154,4 @@ WHERE char *PgpSignAs;
 WHERE char *SmimeDefaultKey;
 WHERE char *SmimeCryptAlg;
 
 WHERE char *SmimeDefaultKey;
 WHERE char *SmimeCryptAlg;
 
-#ifdef MAIN_C
-const char *Months[] =
-  { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
-"Nov", "Dec", "ERR" };
-#else
-extern const char *Months[];
-#endif
-
 #endif /* !_GLOBALS_H */
 #endif /* !_GLOBALS_H */
diff --git a/nntp.c b/nntp.c
index 08814ee..92e0bae 100644 (file)
--- a/nntp.c
+++ b/nntp.c
@@ -801,7 +801,6 @@ static int nntp_save_cache_group (CONTEXT * ctx)
   char file[_POSIX_PATH_MAX];
   FILE *f;
   HEADER *h;
   char file[_POSIX_PATH_MAX];
   FILE *f;
   HEADER *h;
-  struct tm *tm;
   int i = 0, save = SORT_ORDER;
   int prev = 0;
 
   int i = 0, save = SORT_ORDER;
   int prev = 0;
 
@@ -839,21 +838,22 @@ static int nntp_save_cache_group (CONTEXT * ctx)
     i = ctx->msgcount - NntpContext;
   for (; i < ctx->msgcount; i++) {
     if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev) {
     i = ctx->msgcount - NntpContext;
   for (; i < ctx->msgcount; i++) {
     if (!ctx->hdrs[i]->deleted && ctx->hdrs[i]->article_num != prev) {
+      char *loc;
       h = ctx->hdrs[i];
       addr[0] = 0;
       rfc822_addrcat(addr, sizeof(addr), h->env->from, 0);
       h = ctx->hdrs[i];
       addr[0] = 0;
       rfc822_addrcat(addr, sizeof(addr), h->env->from, 0);
-      tm = gmtime (&h->date_sent);
-      snprintf (buf, sizeof (buf),
-                "%d\t%s\t%s\t%d %s %d %02d:%02d:%02d GMT\t%s\t",
-                h->article_num, h->env->subject, addr, tm->tm_mday,
-                Months[tm->tm_mon], tm->tm_year + 1900, tm->tm_hour,
-                tm->tm_min, tm->tm_sec, h->env->message_id);
-      fputs (buf, f);
+
+      loc = setlocale(LC_TIME, "C");
+      strftime(buf, sizeof(buf), "%d %b %Y %H:%M:%S GMT", gmtime(&h->date_sent));
+      setlocale(LC_TIME, loc);
+
+      fprintf(f, "%d\t%s\t%s\t%s\t%s\t\n", h->article_num, h->env->subject,
+              addr, buf, h->env->message_id);
       if (h->env->references)
         mutt_write_references (h->env->references, f);
       if (h->env->references)
         mutt_write_references (h->env->references, f);
-      snprintf (buf, sizeof (buf), "\t%zd\t%d\tXref: %s\n",
-                h->content->length, h->lines, NONULL (h->env->xref));
-      if (fputs (buf, f) == EOF) {
+      if (fprintf(f, "\t%zd\t%d\tXref: %s\n", h->content->length, h->lines,
+                  NONULL(h->env->xref)) == EOF)
+      {
         m_fclose(&f);
         unlink (file);
         return -1;
         m_fclose(&f);
         unlink (file);
         return -1;