mirror of
https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git
synced 2024-12-26 20:23:09 +00:00
Convert dates to epoch.
This commit is contained in:
parent
9c7fb06532
commit
296d599541
@ -15,11 +15,22 @@ sub strip_marks {
|
||||
}
|
||||
|
||||
sub json_to_hash {
|
||||
# This will convert a Json string into a valid
|
||||
# Perl hash for further processing.
|
||||
my $json = shift;
|
||||
my $hash = JSON::PP->new->utf8->decode($json);
|
||||
return $hash;
|
||||
}
|
||||
|
||||
sub date_to_epoch {
|
||||
# This takes the date in YYYY-MM-DD and converts it into
|
||||
# the epoch integer.
|
||||
my $dstring = shift;
|
||||
my $date = Time::Piece->strptime($dstring, '%Y-%m-%d');
|
||||
my $epoch = $date->epoch;
|
||||
return $epoch;
|
||||
}
|
||||
|
||||
sub get_bodhi_eol {
|
||||
# This reads the Bodhi info file (downloaded in collect_web_data.pm),
|
||||
# parses it and returns the EOL date from that file.
|
||||
@ -30,6 +41,7 @@ sub get_bodhi_eol {
|
||||
my $json = script_output("cat ~/version_data/bodhi-$ver.json");
|
||||
my $bodhi = json_to_hash($json);
|
||||
my $eol = $bodhi->{"eol"};
|
||||
$eol = date_to_epoch($eol);
|
||||
return $eol;
|
||||
}
|
||||
|
||||
@ -57,16 +69,22 @@ sub get_schedule_eol {
|
||||
}
|
||||
|
||||
sub get_current_date {
|
||||
# This returns the current date in the required form
|
||||
# YYYY-MM-DD which we need to see if the EOL is
|
||||
# correctly set in the future.
|
||||
# This returns the current date in as the epoch
|
||||
# which we need to see if the EOL is correctly set in the future.
|
||||
my $time = localtime;
|
||||
$time = $time->strftime('%Y-%m-%d');
|
||||
return $time;
|
||||
my $date = $time->strftime('%Y-%m-%d');
|
||||
$date = date_to_epoch($date);
|
||||
return $date;
|
||||
}
|
||||
|
||||
|
||||
sub check_eol {
|
||||
sub check_eol_in_year {
|
||||
# This will take the EOL date from the /etc/os-release
|
||||
# file and it will check that it is at least a year in
|
||||
# the future (when tested on Rawhide, Branched, or Beta)
|
||||
# or that it is at least a year in the future compared
|
||||
# to the previously released version (when tested on a released
|
||||
# version)
|
||||
my $eol = shift;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user