FIX: improved date management

This commit is contained in:
Dominik Meyer 2018-09-15 22:24:05 +02:00
parent bd510ca01a
commit 8e235f9245
No known key found for this signature in database
GPG Key ID: B4C312B600606B64
2 changed files with 46 additions and 3 deletions

View File

@ -282,8 +282,9 @@ sub parseIssue
my $working = $d->find("working");
my $tags = $d->find("tags");
my $id = $tag . "-" . substr($subject->hash(),0,8);
my $cd = $d->timestamp_added();
my $ld = $d->timestamp_last();
my $cd = $d->find("creation_date");
my $ld = $d->find("last_change_date");
my $cld = $d->find("closed_date");
my $author = $d->committer();
# check for required attributes
@ -292,6 +293,26 @@ sub parseIssue
die("severity not available for issue " . $id) unless defined($severity);
die("type not available for issue " . $id) unless defined($type);
#required for backwards compatibility
if (!defined($cd))
{
$cd = $d->timestamp_added();
}
else
{
$cd = $cd->content();
}
#required for backwards compatibility
if (!defined($ld))
{
$ld = $d->timestamp_last();
}
else
{
$ld = $ld->content();
}
my $tz=DateTime::TimeZone->new( name => 'local' );
my $issue = Git::IssueManager::Issue->new(subject => $subject->content);
@ -304,6 +325,11 @@ sub parseIssue
$issue->creation_date(DateTime->from_epoch( epoch =>$cd, time_zone=>$tz));
$issue->last_change_date(DateTime->from_epoch( epoch =>$ld, time_zone=>$tz));
if (defined($cld))
{
$issue->closed_date(DateTime->from_epoch( epoch =>$cld->content, time_zone=>$tz));
}
if (defined($worker))
{
$worker->content()=~/^(.*)\<(.*)\>$/;

View File

@ -493,6 +493,24 @@ sub createIssue
$type->_content($self->type);
$issueTree->add($type);
my $last_changed = $issueTree->newBlob();
$last_changed->path("last_change_date");
$last_changed->_content($self->last_change_date->epoch());
$issueTree->add($last_changed);
my $creation_date = $issueTree->newBlob();
$creation_date->path("creation_date");
$creation_date->_content($self->creation_date->epoch());
$issueTree->add($creation_date);
if ($self->status eq "closed")
{
my $closed_date = $issueTree->newBlob();
$closed_date->path("closed_date");
$closed_date->_content($self->closed_date->epoch());
$issueTree->add($closed_date);
}
if (defined($self->substatus) && length($self->substatus) > 0)
{
my $substatus = $issueTree->newBlob();
@ -543,7 +561,6 @@ sub createIssue
$issueTree->add($tags);
}
return $issueTree;
}