summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorJakub Narebski <jnareb@gmail.com>2006-07-07 20:57:55 +0200
committerJunio C Hamano <junkio@cox.net>2006-07-07 12:17:49 -0700
commit6bdca8905764affcab0c92a60a6a319080d76652 (patch)
tree33d44343b4b5bd26e00a7f521f0789c84289e1cc /git-send-email.perl
parentc9c95bbc9c9f7b8a3c87ab486b4aec220a239577 (diff)
downloadgit-6bdca8905764affcab0c92a60a6a319080d76652.tar.gz
send-email: format 2822 datestring ourselves.
It is not worth trying to force C locale (and failing) just to format the 2822 datestring. This code was borrowed from /usr/bin/822-date (Ian Jackson and Klee Dienes, both in public domain), per suggestion by Eric Wong. Signed-off-by: Junio C Hamano <junkio@cox.net> Acked-by: Jakub Narebski <jnareb@gmail.com>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl41
1 files changed, 38 insertions, 3 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index b04b8f40e9..c9c1975b7f 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -34,8 +34,43 @@ sub readline {
package main;
# most mail servers generate the Date: header, but not all...
-$ENV{LC_ALL} = 'C';
-use POSIX qw/strftime/;
+sub format_2822_time {
+ my ($time) = @_;
+ my @localtm = localtime($time);
+ my @gmttm = gmtime($time);
+ my $localmin = $localtm[1] + $localtm[2] * 60;
+ my $gmtmin = $gmttm[1] + $gmttm[2] * 60;
+ if ($localtm[0] != $gmttm[0]) {
+ die "local zone differs from GMT by a non-minute interval\n";
+ }
+ if ((($gmttm[6] + 1) % 7) == $localtm[6]) {
+ $localmin += 1440;
+ } elsif ((($gmttm[6] - 1) % 7) == $localtm[6]) {
+ $localmin -= 1440;
+ } elsif ($gmttm[6] != $localtm[6]) {
+ die "local time offset greater than or equal to 24 hours\n";
+ }
+ my $offset = $localmin - $gmtmin;
+ my $offhour = $offset / 60;
+ my $offmin = abs($offset % 60);
+ if (abs($offhour) >= 24) {
+ die ("local time offset greater than or equal to 24 hours\n");
+ }
+
+ return sprintf("%s, %2d %s %d %02d:%02d:%02d %s%02d%02d",
+ qw(Sun Mon Tue Wed Thu Fri Sat)[$localtm[6]],
+ $localtm[3],
+ qw(Jan Feb Mar Apr May Jun
+ Jul Aug Sep Oct Nov Dec)[$localtm[4]],
+ $localtm[5]+1900,
+ $localtm[2],
+ $localtm[1],
+ $localtm[0],
+ ($offset >= 0) ? '+' : '-',
+ abs($offhour),
+ $offmin,
+ );
+}
my $have_email_valid = eval { require Email::Valid; 1 };
my $smtp;
@@ -387,7 +422,7 @@ sub send_message
my @recipients = unique_email_list(@to);
my $to = join (",\n\t", @recipients);
@recipients = unique_email_list(@recipients,@cc,@bcclist);
- my $date = strftime('%a, %d %b %Y %H:%M:%S %z', localtime($time++));
+ my $date = format_2822_time($time++);
my $gitversion = '@@GIT_VERSION@@';
if ($gitversion =~ m/..GIT_VERSION../) {
$gitversion = `git --version`;