Skip to content

Commit

Permalink
add note on rendering brick objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Kurowski committed Jan 30, 2023
1 parent 64687f7 commit 6f8465e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,16 @@ $date = \Brick\DateTime\LocalDate::parse('2022-01-01');
$parameters->setDateStartLessThanOrEqualTo($date, reset: true);
```

> Note that semantic value objects from [`brick/date-time`](https://github.com/brick/date-time) are used instead of native `DateTime(Immutable)` class. More on why at [this blogpost](https://jiripudil.cz/blog/beyond-datetime-domain-driven-approach).
> Note that semantic value objects from [`brick/date-time`](https://github.com/brick/date-time) are used instead of native `DateTime(Immutable)` class. More on why at [this blogpost](https://jiripudil.cz/blog/beyond-datetime-domain-driven-approach).
> If you need to render it in human-readable form, you can either use getter or convert it to native object:
> ```php
> /** @var \Brick\DateTime\LocalDate $localDate */
> // using getter
> $localDate->getYear();
> // conversion to native
> $nativeDateTime = $localDate->toNativeDateTimeImmutable();
> $nativeDateTime->format("j. n. Y"); // $nativeDateTime is instance of DateTimeImmutable
> ```
#### Ordering
Expand Down

0 comments on commit 6f8465e

Please sign in to comment.