changeset 93:eb522db0d032 noffle

[svn] Renamed date format and enforce correct date format on post
author bears
date Fri, 19 May 2000 16:14:41 +0100
parents 160a0af71cf8
children be450ac830b2
files src/post.c
diffstat 1 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/post.c	Fri May 19 16:13:44 2000 +0100
+++ b/src/post.c	Fri May 19 16:14:41 2000 +0100
@@ -1,7 +1,7 @@
 /*
   post.c
 
-  $Id: post.c 100 2000-05-18 12:17:23Z bears $
+  $Id: post.c 112 2000-05-19 15:14:41Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -162,6 +162,7 @@
     DynStr * s;
     Str line, field, value;
     Bool replyToFound;
+    time_t t;
 
     s = new_DynStr( 10000 );
     article.text = s;
@@ -186,10 +187,7 @@
 	    DynStr_appLn( s, line );
 	}
 	else if ( strcmp ( field, "date" ) == 0 )
-	{
 	    Utl_cpyStr( article.over.date, value );
-	    DynStr_appLn( s, line );
-	}
 	else if ( strcmp ( field, "references" ) == 0 )
 	{
 	    Utl_cpyStr( article.over.ref, value );
@@ -239,6 +237,20 @@
 	Log_err( "Posted message has no valid Newsgroups field" );
 	return FALSE;
     }
+
+    /* Ensure correctly formatted date */
+    t = Utl_parseNewsDate( article.over.date );
+    if ( t == (time_t) -1 )
+    {
+	time( &t );
+	Utl_newsDate( t, article.over.date );
+	DynStr_app( s, "Date: " );
+	DynStr_appLn( s, article.over.date );
+    }
+    else
+	DynStr_appLn( s, article.over.date );
+
+    /* Ensure Message ID is present and valid */
     if ( Cfg_replaceMsgId() )
     {
 	Prt_genMsgId( article.over.msgId, article.over.from, "NOFFLE" );
@@ -256,21 +268,16 @@
     }
     DynStr_app( s, "Message-ID: " );
     DynStr_appLn( s, article.over.msgId );
+
+    /* Ensure Reply-To header */
     if ( ! replyToFound )
     {
 	Log_dbg( "Adding Reply-To field to posted message." );
 	DynStr_app( s, "Reply-To: " );
 	DynStr_appLn( s, article.over.from );
     }
-    if ( article.over.date[ 0 ] == '\0' )
-    {
-	time_t t;
 
-	time( &t );
-	Utl_rfc822Date( t, article.over.date );
-	DynStr_app( s, "Date: " );
-	DynStr_appLn( s, article.over.date );
-    }
+    /* OK, header ready to roll. Something to accompany it? */
     if ( p == NULL || p[ 0 ] == '\0' )
     {
 	Log_err( "Posted  message has no body" );