1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-12-28 05:03:09 +00:00

Convert dates to epoch.

This commit is contained in:
Lukas Ruzicka 2024-11-28 12:24:51 +01:00
parent 9c7fb06532
commit 296d599541

View File

@ -15,11 +15,22 @@ sub strip_marks {
} }
sub json_to_hash { sub json_to_hash {
# This will convert a Json string into a valid
# Perl hash for further processing.
my $json = shift; my $json = shift;
my $hash = JSON::PP->new->utf8->decode($json); my $hash = JSON::PP->new->utf8->decode($json);
return $hash; 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 { sub get_bodhi_eol {
# This reads the Bodhi info file (downloaded in collect_web_data.pm), # This reads the Bodhi info file (downloaded in collect_web_data.pm),
# parses it and returns the EOL date from that file. # 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 $json = script_output("cat ~/version_data/bodhi-$ver.json");
my $bodhi = json_to_hash($json); my $bodhi = json_to_hash($json);
my $eol = $bodhi->{"eol"}; my $eol = $bodhi->{"eol"};
$eol = date_to_epoch($eol);
return $eol; return $eol;
} }
@ -57,16 +69,22 @@ sub get_schedule_eol {
} }
sub get_current_date { sub get_current_date {
# This returns the current date in the required form # This returns the current date in as the epoch
# YYYY-MM-DD which we need to see if the EOL is # which we need to see if the EOL is correctly set in the future.
# correctly set in the future.
my $time = localtime; my $time = localtime;
$time = $time->strftime('%Y-%m-%d'); my $date = $time->strftime('%Y-%m-%d');
return $time; $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; my $eol = shift;
} }