Use local time.
Signed-off-by: Thomas Hochstein <thh@thh.name>
This commit is contained in:
parent
d28ca61a32
commit
585f877bd2
2 changed files with 14 additions and 8 deletions
|
|
@ -5,6 +5,7 @@ yapfaq 1.0.0 (unreleased)
|
||||||
* Show next posting date if posting is not due.
|
* Show next posting date if posting is not due.
|
||||||
* Add --simulation mode.
|
* Add --simulation mode.
|
||||||
* Update examples in POD.
|
* Update examples in POD.
|
||||||
|
* Use local time.
|
||||||
|
|
||||||
yapfaq 0.10 (unreleased)
|
yapfaq 0.10 (unreleased)
|
||||||
* Add: Charset definition.
|
* Add: Charset definition.
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ sub ParseDate {
|
||||||
return DateTime->new(year => $Year,
|
return DateTime->new(year => $Year,
|
||||||
month => $Month,
|
month => $Month,
|
||||||
day => $Day,
|
day => $Day,
|
||||||
);
|
)->set_time_zone('local');
|
||||||
}
|
}
|
||||||
|
|
||||||
### ------------------------------------------------------------------
|
### ------------------------------------------------------------------
|
||||||
|
|
@ -377,6 +377,9 @@ sub BuildPosting {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# today (TD)
|
||||||
|
my $TD = DateTime->now->set_time_zone('local');
|
||||||
|
|
||||||
# read status file, if available
|
# read status file, if available
|
||||||
my($LastPosted, $LastMID);
|
my($LastPosted, $LastMID);
|
||||||
if (-r $StatusFile) {
|
if (-r $StatusFile) {
|
||||||
|
|
@ -409,7 +412,7 @@ sub BuildPosting {
|
||||||
}
|
}
|
||||||
|
|
||||||
# add Date:
|
# 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:
|
# add missing Message-ID:
|
||||||
push @Headers, 'Message-ID: <%n-%y-%m-%d@' . hostfqdn. ">\n" if (!$Header{'message-id'});
|
push @Headers, 'Message-ID: <%n-%y-%m-%d@' . hostfqdn. ">\n" if (!$Header{'message-id'});
|
||||||
# add User-Agent
|
# add User-Agent
|
||||||
|
|
@ -462,9 +465,9 @@ sub BuildPosting {
|
||||||
# %d current day
|
# %d current day
|
||||||
# %p PID
|
# %p PID
|
||||||
if (/^Message-ID: /i) {
|
if (/^Message-ID: /i) {
|
||||||
my $TDY = DateTime->now->strftime('%Y');
|
my $TDY = $TD->strftime('%Y');
|
||||||
my $TDM = DateTime->now->strftime('%m');
|
my $TDM = $TD->strftime('%m');
|
||||||
my $TDD = DateTime->now->strftime('%d');
|
my $TDD = $TD->strftime('%d');
|
||||||
$_ =~ s/\%n/$Project/g;
|
$_ =~ s/\%n/$Project/g;
|
||||||
$_ =~ s/\%y/$TDY/g;
|
$_ =~ s/\%y/$TDY/g;
|
||||||
$_ =~ s/\%m/$TDM/g;
|
$_ =~ s/\%m/$TDM/g;
|
||||||
|
|
@ -481,7 +484,9 @@ sub BuildPosting {
|
||||||
chomp;
|
chomp;
|
||||||
$_ =~ s/^Expires:\s+//;
|
$_ =~ s/^Expires:\s+//;
|
||||||
die "E: Illegal 'Expires: $_' in '$HeaderFile'.\n" if ($_ !~ /^\d+[dwmy]$/);
|
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
|
# add Supersedes: if set
|
||||||
if (/^Supersedes: /) {
|
if (/^Supersedes: /) {
|
||||||
|
|
@ -518,7 +523,7 @@ sub BuildPosting {
|
||||||
|
|
||||||
# check if posting is due
|
# check if posting is due
|
||||||
print "- Posting has been forced.\n" if $Config{'debug'} && $OptForce;
|
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'};
|
print "... is due and will be posted.\n" if $Config{'verbose'} or $Config{'debug'};
|
||||||
} else {
|
} else {
|
||||||
printf("... is not due (next post at %s).\n", $NextPosted->strftime('%Y-%m-%d'))
|
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 $StatusFile = $Config{'datadir'} . "$Project.cfg";
|
||||||
my @Status;
|
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";
|
push @Status, "Last-Message-ID: $LastMID\n";
|
||||||
|
|
||||||
$StatusFile = path($StatusFile);
|
$StatusFile = path($StatusFile);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue