From 52c551bb830c7e0e70adbe514985c8a592bdd0b0 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 13 Apr 2003 03:46:21 +0000 Subject: [PATCH] Added a date stamp to outgoing mail to maintain compliance with the RFC2822 specification. --- lib/WebGUI/DateTime.pm | 28 +++++++++++++++++++++++----- lib/WebGUI/Mail.pm | 2 ++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/WebGUI/DateTime.pm b/lib/WebGUI/DateTime.pm index 4050727ab..cca39ddd6 100644 --- a/lib/WebGUI/DateTime.pm +++ b/lib/WebGUI/DateTime.pm @@ -175,6 +175,7 @@ A string representing the output format for the date. Defaults to '%z %Z'. You c %% = % (percent) symbol. %c = The calendar month name. + %C = The calendar month name abbreviated to 3 characters and represented in English. %d = A two digit day. %D = A variable digit day. %h = A two digit hour (on a 12 hour clock). @@ -184,10 +185,13 @@ A string representing the output format for the date. Defaults to '%z %Z'. You c %m = A two digit month. %M = A variable digit month. %n = A two digit minute. + %o = Offset from GMT represented as an integer. + %O = Offset from GMT represented in four digit form with a sign. Example: -0600 %p = A lower-case am/pm. %P = An upper-case AM/PM. %s = A two digit second. - %w = The name of the week. + %w = Day of the week. + %W = Day of the week abbreviated to 3 characters and represented in English. %y = A four digit year. %Y = A two digit year. %z = The current user's date format preference. @@ -205,6 +209,12 @@ sub epochToHuman { $temp = $temp+$offset; my ($year,$month,$day,$hour,$min,$sec) = Date::Calc::Time_to_Date($temp); $output = $_[1] || "%z %Z"; + #---GMT Offsets + $temp = $session{user}{timeOffset}*100; + $temp = sprintf('%+05d',$temp); + $output =~ s/\%O/$temp/g; + $temp = $session{user}{timeOffset}+0; + $output =~ s/\%o/$temp/g; #---dealing with percent symbol $output =~ s/\%\%/\%/g; #---date format preference @@ -222,16 +232,24 @@ sub epochToHuman { $output =~ s/\%m/$value/g; $output =~ s/\%M/$month/g; if ($output =~ /\%c/) { - my $monthName = getMonthName($month); - $output =~ s/\%c/$monthName/g; + $temp = getMonthName($month); + $output =~ s/\%c/$temp/g; + } + if ($output =~ /\%C/) { + $temp = substr(Date::Calc::Month_to_Text($month),0,3); + $output =~ s/\%C/$temp/g; } #---day stuff $value = sprintf("%02d",$day); $output =~ s/\%d/$value/g; $output =~ s/\%D/$day/g; if ($output =~ /\%w/) { - my $dayName = getDayName(Date::Calc::Day_of_Week($year,$month,$day)); - $output =~ s/\%w/$dayName/g; + $temp = getDayName(Date::Calc::Day_of_Week($year,$month,$day)); + $output =~ s/\%w/$temp/g; + } + if ($output =~ /%W/) { + $temp = Date::Calc::Day_of_Week_Abbreviation(Date::Calc::Day_of_Week($year,$month,$day)); + $output =~ s/\%W/$temp/g; } #---hour stuff $hour12 = $hour; diff --git a/lib/WebGUI/Mail.pm b/lib/WebGUI/Mail.pm index dc2a7dad3..b8cdffa7a 100644 --- a/lib/WebGUI/Mail.pm +++ b/lib/WebGUI/Mail.pm @@ -16,6 +16,7 @@ package WebGUI::Mail; use Net::SMTP; use strict; +use WebGUI::DateTime; use WebGUI::ErrorHandler; use WebGUI::Macro; use WebGUI::Session; @@ -86,6 +87,7 @@ sub send { $message .= "CC: $_[3]\n" if ($_[3]); $message .= "BCC: $_[5]\n" if ($_[5]); $message .= "Subject: ".$_[1]."\n"; + $message .= "Date: ".WebGUI::DateTime::epochToHuman("","%W, %d %C %y %j:%n:%s %O")."\n"; $message .= "\n"; $message = WebGUI::Macro::process($message); #body