Created
November 25, 2016 01:25
-
-
Save larowlan/c30d686070545073ad9529a6530af3f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Commands/Billable.php b/src/Commands/Billable.php | |
index 2df9683..39bb721 100644 | |
--- a/src/Commands/Billable.php | |
+++ b/src/Commands/Billable.php | |
@@ -28,6 +28,7 @@ class Billable extends Command implements ConfigurableService { | |
const DAY = 'day'; | |
const MONTH = 'month'; | |
const FORTNIGHT = 'fortnight'; | |
+ const SATURDAY = 6; | |
/** | |
* @var \Larowlan\Tl\Connector\Connector | |
@@ -260,14 +261,19 @@ class Billable extends Command implements ConfigurableService { | |
protected function getWeekdaysPassedThisMonth() { | |
$days_passed = date('d'); | |
- $weekends_passed = round($days_passed / 7); | |
- $days_passed -= ($weekends_passed * 2); | |
- | |
- // Don't include the current day before 3pm? | |
+ $weekdays = 0; | |
+ for ($i = 0; $i < $days_passed; $i++) { | |
+ $day_of_week = DateHelper::startOfMonth() | |
+ ->modify(sprintf('+%d days', $i)) | |
+ ->format('w'); | |
+ if ($day_of_week && $day_of_week != self::SATURDAY) { | |
+ $weekdays++; | |
+ } | |
+ } | |
if (date('G') < 15) { | |
- $days_passed -= 1; | |
+ $weekdays -= 1; | |
} | |
- return $days_passed; | |
+ return $weekdays; | |
} | |
/** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment