aboutsummaryrefslogtreecommitdiff
path: root/command
diff options
context:
space:
mode:
authorMaZderMind2016-12-11 20:27:35 +0100
committerMaZderMind2016-12-11 20:38:30 +0100
commit8beec6fda376b842a9ddb7a2425829690f0a8b48 (patch)
tree49ef2cb90694aa16aa34fd0b0f261f28ccfd41df /command
parent3c3d0ac7301e818b14d01b9bbc949ca13d2cf798 (diff)
use DateTime objects for ends/startsAt
Diffstat (limited to 'command')
-rw-r--r--command/download.php32
1 files changed, 25 insertions, 7 deletions
diff --git a/command/download.php b/command/download.php
index 8cc2f53..cb0987d 100644
--- a/command/download.php
+++ b/command/download.php
@@ -15,14 +15,32 @@ if(isset($conf['REQUIRE_USER']))
}
}
-foreach (Conferences::getConferences() as $conference)
+$conferences = Conferences::getConferences();
+
+if(isset($conf['MAX_CONFERENCE_AGE']))
{
- stdout('== %s ==', $conference->getSlug());
+ $months = intval($conf['MAX_CONFERENCE_AGE']);
+ $conferencesAfter = new DateTime();
+ $conferencesAfter->sub(new DateInterval('P'.$months.'D'));
- if(isset($conf['MAX_CONFERENCE_AGE']))
- {
- date_diff()
- return time() >= $this->endsAt();
- }
+ stdout('Filtering before %s', $conferencesAfter->format('Y-m-d'));
+ $conferences = array_filter($conferences, function($conference) use ($conferencesAfter) {
+ $isBefore = $conference->endsAt() < $conferencesAfter;
+
+ if($isBefore) {
+ stdout(
+ ' %s: %s',
+ $conference->endsAt()->format('Y-m-d'),
+ $conference->getSlug()
+ );
+ }
+ return !$isBefore;
+ });
+}
+
+stdout('');
+foreach ($conferences as $conference)
+{
+ stdout('== %s ==', $conference->getSlug());
}