brick / date-time

Date and time library for PHP
MIT License
321 stars 29 forks source link

Year::atMonth() should accept a Month #94

Closed gnutix closed 3 months ago

gnutix commented 3 months ago

Hello there,

I'm in the process of upgrading to 0.6, and I've noticed this in the changelog :

YearWeek: the atDay() method now accepts a DayOfWeek instance, passing an integer is deprecated

I'm surprised that the same wasn't done for atMonth. I found a usage in our code I expected to just work, but I had to add ->value instead to get the int.

Is it something that was simply forgotten ? Or is there a reason ? gnutix

BenMorel commented 3 months ago

I think you mean:

Year::atMonth() should accept a ~YearMonth ?~ Month?

Then most definitely yes, it was forgotten. Do you want to open a PR?

gnutix commented 3 months ago

Yes sorry, I meant a Month indeed. Example :

Year::parse('2024')->atMonth(Month::JANUARY->value)->getFirstDay(); // equals 2024-01-01
gnutix commented 3 months ago

PR done : https://github.com/brick/date-time/pull/95