Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimeFormat: support quick access properties #302

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

h4kuna
Copy link
Contributor

@h4kuna h4kuna commented Sep 13, 2023

  • new feature? yes
  • BC break? no
  • doc PR: nette/docs#??? if you agree with theses changes I will write.

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);

@dg dg force-pushed the master branch 14 times, most recently from 6733224 to 5de10a1 Compare June 18, 2024 21:22
@dg dg force-pushed the master branch 16 times, most recently from a846fab to 736c567 Compare August 7, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants