Skip to content

Commit 810e6fa

Browse files
author
Christian Kolb
committed
Fix construction
1 parent c42a2b7 commit 810e6fa

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/Date.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
public function __construct(
2222
public Month $month,
23-
public int $day,
23+
public Day $day,
2424
) {
2525
}
2626

@@ -44,7 +44,9 @@ public static function fromDateTime(\DateTimeImmutable $dateTime): self
4444
new Year($year),
4545
$month,
4646
),
47-
$day,
47+
new Day(
48+
$day,
49+
),
4850
);
4951
}
5052

@@ -376,7 +378,7 @@ public function toMomentInTimeZone(\DateTimeZone $timeZone): Moment
376378
'%d-%d-%d 00:00:00',
377379
$this->month->year->year,
378380
$this->month->month,
379-
$this->day,
381+
$this->day->day,
380382
),
381383
$timeZone,
382384
);
@@ -389,7 +391,7 @@ public function modifyInTimeZone(string $modify, \DateTimeZone $timeZone): self
389391
'%d-%d-%d 00:00:00',
390392
$this->month->year->year,
391393
$this->month->month,
392-
$this->day,
394+
$this->day->day,
393395
),
394396
$timeZone,
395397
);
@@ -405,7 +407,7 @@ private function toDateTimeImmutable(): \DateTimeImmutable
405407
'%d-%d-%d 00:00:00',
406408
$this->month->year->year,
407409
$this->month->month,
408-
$this->day,
410+
$this->day->day,
409411
),
410412
);
411413
}

tests/Date/ConstructionTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace DigitalCraftsman\DateTimePrecision\Date;
66

77
use DigitalCraftsman\DateTimePrecision\Date;
8+
use DigitalCraftsman\DateTimePrecision\Day;
89
use DigitalCraftsman\DateTimePrecision\Month;
910
use DigitalCraftsman\DateTimePrecision\Year;
1011
use PHPUnit\Framework\TestCase;
@@ -25,11 +26,13 @@ public function construct_works(): void
2526
new Year(2022),
2627
10,
2728
),
28-
8,
29+
new Day(
30+
8,
31+
),
2932
);
3033

3134
// -- Assert
32-
self::assertSame(8, $date->day);
35+
self::assertSame(8, $date->day->day);
3336
}
3437

3538
/**

0 commit comments

Comments
 (0)