Skip to content

Commit 6e2cf08

Browse files
Add days before expiration in "about" command
1 parent 57a10ef commit 6e2cf08

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Command/AboutCommand.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6666
new TableSeparator(),
6767
['Version', Kernel::VERSION],
6868
['Long-Term Support', 4 === Kernel::MINOR_VERSION ? 'Yes' : 'No'],
69-
['End of maintenance', Kernel::END_OF_MAINTENANCE.(self::isExpired(Kernel::END_OF_MAINTENANCE) ? ' <error>Expired</>' : '')],
70-
['End of life', Kernel::END_OF_LIFE.(self::isExpired(Kernel::END_OF_LIFE) ? ' <error>Expired</>' : '')],
69+
['End of maintenance', Kernel::END_OF_MAINTENANCE.(self::isExpired(Kernel::END_OF_MAINTENANCE) ? ' <error>Expired</>' : ' (<comment>'.self::daysBeforeExpiration(Kernel::END_OF_MAINTENANCE).'</>)')],
70+
['End of life', Kernel::END_OF_LIFE.(self::isExpired(Kernel::END_OF_LIFE) ? ' <error>Expired</>' : ' (<comment>'.self::daysBeforeExpiration(Kernel::END_OF_LIFE).'</>)')],
7171
new TableSeparator(),
7272
['<info>Kernel</>'],
7373
new TableSeparator(),
@@ -119,4 +119,11 @@ private static function isExpired(string $date): bool
119119

120120
return false !== $date && new \DateTime() > $date->modify('last day of this month 23:59:59');
121121
}
122+
123+
private static function daysBeforeExpiration(string $date): string
124+
{
125+
$date = \DateTime::createFromFormat('d/m/Y', '01/'.$date);
126+
127+
return (new \DateTime())->diff($date->modify('last day of this month 23:59:59'))->format('in %R%a days');
128+
}
122129
}

0 commit comments

Comments
 (0)