diff --git a/ChangeLog b/ChangeLog index b66b4b0..f0f3a05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ yapfaq 1.0.0 (unreleased) * Show next posting date if posting is not due. * Add --simulation mode. * Update examples in POD. +* Use local time. yapfaq 0.10 (unreleased) * Add: Charset definition. diff --git a/bin/yapfaq.pl b/bin/yapfaq.pl index 4013b2a..89ae88d 100755 --- a/bin/yapfaq.pl +++ b/bin/yapfaq.pl @@ -238,7 +238,7 @@ sub ParseDate { return DateTime->new(year => $Year, month => $Month, day => $Day, - ); + )->set_time_zone('local'); } ### ------------------------------------------------------------------ @@ -377,6 +377,9 @@ sub BuildPosting { return ''; } + # today (TD) + my $TD = DateTime->now->set_time_zone('local'); + # read status file, if available my($LastPosted, $LastMID); if (-r $StatusFile) { @@ -409,7 +412,7 @@ sub BuildPosting { } # add Date: - push @Headers, 'Date: ' . DateTime->now->strftime('%a, %d %b %Y %H:%M:%S %z') . "\n"; + push @Headers, 'Date: ' . $TD->strftime('%a, %d %b %Y %H:%M:%S %z') . "\n"; # add missing Message-ID: push @Headers, 'Message-ID: <%n-%y-%m-%d@' . hostfqdn. ">\n" if (!$Header{'message-id'}); # add User-Agent @@ -462,9 +465,9 @@ sub BuildPosting { # %d current day # %p PID if (/^Message-ID: /i) { - my $TDY = DateTime->now->strftime('%Y'); - my $TDM = DateTime->now->strftime('%m'); - my $TDD = DateTime->now->strftime('%d'); + my $TDY = $TD->strftime('%Y'); + my $TDM = $TD->strftime('%m'); + my $TDD = $TD->strftime('%d'); $_ =~ s/\%n/$Project/g; $_ =~ s/\%y/$TDY/g; $_ =~ s/\%m/$TDM/g; @@ -481,7 +484,9 @@ sub BuildPosting { chomp; $_ =~ s/^Expires:\s+//; die "E: Illegal 'Expires: $_' in '$HeaderFile'.\n" if ($_ !~ /^\d+[dwmy]$/); - $_ = 'Expires: ' . &AddDuration(DateTime->now,$_)->strftime('%a, %d %b %Y %H:%M:%S %z') . "\n"; + $_ = 'Expires: ' . &AddDuration($TD,$_)->strftime('%a, %d %b %Y %H:%M:%S %z') . "\n"; + # reset TD (changed by AddDuration) + $TD = DateTime->now->set_time_zone('local'); } # add Supersedes: if set if (/^Supersedes: /) { @@ -518,7 +523,7 @@ sub BuildPosting { # check if posting is due print "- Posting has been forced.\n" if $Config{'debug'} && $OptForce; - if ($OptForce or (!$LastPosted) or ($LastPosted && $NextPosted <= DateTime->now)) { + if ($OptForce or (!$LastPosted) or ($LastPosted && $NextPosted <= $TD)) { print "... is due and will be posted.\n" if $Config{'verbose'} or $Config{'debug'}; } else { printf("... is not due (next post at %s).\n", $NextPosted->strftime('%Y-%m-%d')) @@ -569,7 +574,7 @@ sub UpdateStatus { my $StatusFile = $Config{'datadir'} . "$Project.cfg"; my @Status; - push @Status, "Last-Posted: " . DateTime->now->strftime('%Y-%m-%d') . "\n"; + push @Status, "Last-Posted: " . DateTime->now->set_time_zone('local')->strftime('%Y-%m-%d') . "\n"; push @Status, "Last-Message-ID: $LastMID\n"; $StatusFile = path($StatusFile);