Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion exercises/practice/perfect-numbers/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
},
"blurb": "Determine if a number is perfect, abundant, or deficient based on Nicomachus' (60 - 120 CE) classification scheme for positive integers.",
"source": "Taken from Chapter 2 of Functional Thinking by Neal Ford.",
"source_url": "https://www.oreilly.com/library/view/functional-thinking/9781449365509/"
"source_url": "https://nealford.com/books/functionalthinking.html"
}
16 changes: 8 additions & 8 deletions exercises/practice/swift-scheduling/.meta/example.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private function convertNow(DateTime $meetingStart): DateTime

private function convertAsap(DateTime $meetingStart): DateTime
{
$meetingHour = (int) $meetingStart->format('H');
$meetingHour = $meetingStart->format('H');

return $meetingHour < 13
? $meetingStart->setTime(17, 0)
Expand All @@ -52,7 +52,7 @@ private function convertAsap(DateTime $meetingStart): DateTime

private function convertEow(DateTime $meetingStart): DateTime
{
$meetingDay = (int) $meetingStart->format('w');
$meetingDay = (int) $meetingStart->format('N');

return $meetingDay === 1 || $meetingDay === 2 || $meetingDay === 3
? $meetingStart->modify("friday")
Expand All @@ -63,7 +63,7 @@ private function convertEow(DateTime $meetingStart): DateTime

private function convertVariableM(DateTime $meetingStart, int $dueMonth): DateTime
{
$meetingMonth = (int) $meetingStart->format('m');
$meetingMonth = $meetingStart->format('m');

$meetingMonth < $dueMonth
? $meetingStart->setDate(
Expand All @@ -72,23 +72,23 @@ private function convertVariableM(DateTime $meetingStart, int $dueMonth): DateTi
1
)
: $meetingStart->setDate(
(int) $meetingStart->format('Y') + 1,
$meetingStart->format('Y') + 1,
$dueMonth,
1
);

$meetingDay = (int) $meetingStart->format('w');
$meetingDay = (int) $meetingStart->format('N');

return $meetingDay === 0 || $meetingDay === 6
return $meetingDay === 6
? $meetingStart->modify("first weekday")
->setTime(8, 0)
: $meetingStart->setTime(8, 0);
}

private function convertVariableQ(DateTime $meetingStart, int $dueQuarter): DateTime
{
$meetingMonth = (int) $meetingStart->format('m');
$meetingQuarter = round(($meetingMonth + 2) / 3);
$meetingMonth = $meetingStart->format('m');
$meetingQuarter = intdiv($meetingMonth + 2, 3);

$meetingStart->setDate(
(int) $meetingStart->format('Y'),
Expand Down
3 changes: 3 additions & 0 deletions exercises/practice/swift-scheduling/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ description = "Q4 in the second quarter translates to the last workday of the fo

[c920886c-44ad-4d34-a156-dc4176186581]
description = "Q3 in the fourth quarter translates to the last workday of the third quarter of next year"

[7c8f1616-be62-417e-bbd5-a60fa743eccc]
description = "Q2 starting in the last month of the second quarter translates to the last workday of the second quarter of this year"
14 changes: 14 additions & 0 deletions exercises/practice/swift-scheduling/SwiftSchedulingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,4 +235,18 @@ public function testQThreeInTheFourthQuarterTranslatesToTheLastWorkdayOfTheThird

$this->assertEquals($expected, $swiftScheduling->deliveryDate($description));
}

/**
* uuid: 7c8f1616-be62-417e-bbd5-a60fa743eccc
*/
#[TestDox('Q2 starting in the last month of the second quarter translates to the last workday of the second quarter of this year')]
public function testQTwoStartingInTheLastMonthOfTheSecondQuarterTranslatesToTheLastWorkdayOfTheSecondQuarterOfThisYear(): void
{
$description = "Q2";
$meetingStart = new DateTime("2019-06-15T09:50:00");
$expected = new DateTime("2019-06-28T08:00:00");
$swiftScheduling = new SwiftScheduling($meetingStart);

$this->assertEquals($expected, $swiftScheduling->deliveryDate($description));
}
}
Loading