File tree Expand file tree Collapse file tree 5 files changed +49
-6
lines changed
Expand file tree Collapse file tree 5 files changed +49
-6
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ $config = PhpCsFixer\Config::create()
2424 'concat_space ' => ['spacing ' => 'one ' ],
2525 'ordered_imports ' => true ,
2626 'array_syntax ' => ['syntax ' => 'short ' ],
27+ 'yoda_style ' => false ,
2728 ])
2829 ->setFinder ($ finder );
2930
Original file line number Diff line number Diff line change 11language : php
22
33php :
4+ - 7.0
45 - 7.1
56
67# faster builds on new travis setup not using sudo
@@ -18,4 +19,4 @@ install:
1819
1920script :
2021 - vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run --diff
21- - phpunit
22+ - vendor/bin/ phpunit --verbose
Original file line number Diff line number Diff line change @@ -274,8 +274,8 @@ public function dailyAt($time)
274274 {
275275 $ segments = explode (': ' , $ time );
276276
277- return $ this ->spliceIntoPosition (2 , (int )$ segments [0 ])
278- ->spliceIntoPosition (1 , count ($ segments ) == 2 ? (int )$ segments [1 ] : '0 ' );
277+ return $ this ->spliceIntoPosition (2 , (int ) $ segments [0 ])
278+ ->spliceIntoPosition (1 , count ($ segments ) == 2 ? (int ) $ segments [1 ] : '0 ' );
279279 }
280280
281281 /**
@@ -509,6 +509,22 @@ public function timezone($timezone)
509509 return $ this ;
510510 }
511511
512+ /**
513+ * @return bool
514+ */
515+ public function hasTimezone ()
516+ {
517+ return $ this ->_timezone !== null ;
518+ }
519+
520+ /**
521+ * @return \DateTimeZone|string
522+ */
523+ public function getTimezone ()
524+ {
525+ return $ this ->_timezone ;
526+ }
527+
512528 /**
513529 * Set which user the command should run as.
514530 *
Original file line number Diff line number Diff line change 22
33namespace yii2mod \scheduling ;
44
5+ use Carbon \Carbon ;
6+ use Cron \CronExpression ;
57use League \CLImate \CLImate ;
68use Yii ;
79use yii \base \InvalidConfigException ;
@@ -82,9 +84,12 @@ public function actionList()
8284 foreach ($ this ->schedule ->getEvents () as $ event ) {
8385 $ data [] = [
8486 '# ' => ++$ row ,
85- 'Task ' => $ event ->getDescription (),
87+ 'Task ' => $ event ->getSummaryForDisplay (),
8688 'Expression ' => $ event ->getExpression (),
87- 'Command to Run ' => $ event ->command ,
89+ 'Command to Run ' => is_a ($ event , CallbackEvent::class)
90+ ? $ event ->getSummaryForDisplay ()
91+ : $ event ->command ,
92+ 'Next run at ' => $ this ->getNextRunDate ($ event ),
8893 ];
8994 }
9095
@@ -109,4 +114,23 @@ protected function importScheduleFile()
109114 include $ scheduleFile ;
110115 });
111116 }
117+
118+ /**
119+ * Get the next scheduled run date for this event
120+ *
121+ * @param Event $event
122+ *
123+ * @return string
124+ */
125+ protected function getNextRunDate (Event $ event )
126+ {
127+ $ cron = CronExpression::factory ($ event ->getExpression ());
128+ $ date = Carbon::now ();
129+
130+ if ($ event ->hasTimezone ()) {
131+ $ date ->setTimezone ($ event ->getTimezone ());
132+ }
133+
134+ return $ cron ->getNextRunDate ()->format ('Y-m-d H:i:s ' );
135+ }
112136}
Original file line number Diff line number Diff line change 2222 "guzzlehttp/guzzle" : " ^6.3"
2323 },
2424 "require-dev" : {
25- "friendsofphp/php-cs-fixer" : " ~2.0"
25+ "friendsofphp/php-cs-fixer" : " ~2.0" ,
26+ "phpunit/phpunit" : " ~6.0"
2627 },
2728 "autoload" : {
2829 "psr-4" : {
You can’t perform that action at this time.
0 commit comments