fix default value for old events, and actually bail out if "old" is less than six days ago (fixes #49)

This commit is contained in:
Florian Schlichting 2015-10-02 22:44:51 +02:00
parent 8895aac2bf
commit d7b063a249

View File

@ -1,7 +1,7 @@
#!/usr/bin/env php #!/usr/bin/env php
<?php <?php
/** /**
* Script to refresh the pending alarm times for the next alarm instance. * Script to move old events into an archive collection
* *
* @package davical * @package davical
* @subpackage alarms * @subpackage alarms
@ -17,7 +17,7 @@ $_SERVER['SERVER_NAME'] = 'localhost';
/** /**
* Call with something like e.g.: * Call with something like e.g.:
* *
* scripts/archive-old-events.php -a archive -p karora -o P93D * scripts/archive-old-events.php -a archive -p karora -c calendar -o P-93D
* *
*/ */
@ -26,7 +26,7 @@ $args->debug = false;
$args->principal = false; $args->principal = false;
$args->collection = false; $args->collection = false;
$args->older = 'P190D'; $args->older = 'P-190D';
$args->delete = false; $args->delete = false;
$args->archive_suffix = 'archive'; $args->archive_suffix = 'archive';
$debugging = null; $debugging = null;
@ -113,7 +113,8 @@ $recent->modify('P-6D');
$archive_before_date = new RepeatRuleDateTime(gmdate('Ymd\THis\Z')); $archive_before_date = new RepeatRuleDateTime(gmdate('Ymd\THis\Z'));
$archive_before_date->modify( $args->older ); $archive_before_date->modify( $args->older );
if ( $archive_before_date > $recent ) { if ( $archive_before_date > $recent ) {
echo "Cowardly refusing to archive events before "+$archive_before_date->format('Y-m-d H:i:s') + "\n"; echo "Cowardly refusing to archive events before " . $archive_before_date->format('Y-m-d H:i:s') . "\n";
exit(1);
} }