File tree 5 files changed +49
-6
lines changed
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()
24
24
'concat_space ' => ['spacing ' => 'one ' ],
25
25
'ordered_imports ' => true ,
26
26
'array_syntax ' => ['syntax ' => 'short ' ],
27
+ 'yoda_style ' => false ,
27
28
])
28
29
->setFinder ($ finder );
29
30
Original file line number Diff line number Diff line change 1
1
language : php
2
2
3
3
php :
4
+ - 7.0
4
5
- 7.1
5
6
6
7
# faster builds on new travis setup not using sudo
@@ -18,4 +19,4 @@ install:
18
19
19
20
script :
20
21
- 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)
274
274
{
275
275
$ segments = explode (': ' , $ time );
276
276
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 ' );
279
279
}
280
280
281
281
/**
@@ -509,6 +509,22 @@ public function timezone($timezone)
509
509
return $ this ;
510
510
}
511
511
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
+
512
528
/**
513
529
* Set which user the command should run as.
514
530
*
Original file line number Diff line number Diff line change 2
2
3
3
namespace yii2mod \scheduling ;
4
4
5
+ use Carbon \Carbon ;
6
+ use Cron \CronExpression ;
5
7
use League \CLImate \CLImate ;
6
8
use Yii ;
7
9
use yii \base \InvalidConfigException ;
@@ -82,9 +84,12 @@ public function actionList()
82
84
foreach ($ this ->schedule ->getEvents () as $ event ) {
83
85
$ data [] = [
84
86
'# ' => ++$ row ,
85
- 'Task ' => $ event ->getDescription (),
87
+ 'Task ' => $ event ->getSummaryForDisplay (),
86
88
'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 ),
88
93
];
89
94
}
90
95
@@ -109,4 +114,23 @@ protected function importScheduleFile()
109
114
include $ scheduleFile ;
110
115
});
111
116
}
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
+ }
112
136
}
Original file line number Diff line number Diff line change 22
22
"guzzlehttp/guzzle" : " ^6.3"
23
23
},
24
24
"require-dev" : {
25
- "friendsofphp/php-cs-fixer" : " ~2.0"
25
+ "friendsofphp/php-cs-fixer" : " ~2.0" ,
26
+ "phpunit/phpunit" : " ~6.0"
26
27
},
27
28
"autoload" : {
28
29
"psr-4" : {
You can’t perform that action at this time.
0 commit comments