nette / utils

🛠 Lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.
https://doc.nette.org/utils
Other
1.98k stars 147 forks source link

DateTimeFormat: support quick access properties #302

Open h4kuna opened 1 year ago

h4kuna commented 1 year ago

I add trait DateTimeFormat what extends class DateTime, with quick access to frequent date and time values with right type.

I used SmartObject and added read-only properties for DateTime.

Example

use Nette\Utils\DateTime;

$now = new DateTime('2023-09-13');
dump($now->year === 2023); // true
dump($now->year === '2023'); // false, 2023 is string
dump($now->month === 9);
dump($now->day === 13);
h4kuna commented 6 months ago

If you don't like it, let's close it.