skybluesofa / onthisday

Get fun events and holidays for a given day.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add 'when is' functionality

skybluesofa opened this issue · comments

This is a reverse lookup of events/holidays. When a name is passed in, it should return an array of Carbon dates for the given event/holiday name. The reason for the array value is that, there are some events that have the same name, but have been proposed by different sponsors. In this case, both dates would be returned in the array.

For instance, if the method OnThisDay::whenIs('Halloween') is run during 2016, the return value would be [Carbon '10/31/2016'].

Another instance, if the method OnThisDay::whenIs('Thanksgiving', '2012') is run, the return value would be [Carbon '11/22/2012'].

Requirements:

  • Use the supplied method signature in the OnThisDay class.
  • The first argument (event name) should not be case sensitive.
  • The second argument, if provided should allow for a 2 or 4 digit year
  • The second argument, if not provided should default to the current year
  • The return value would be an array of Carbon dates
  • Unit tests have already been written: the test_when_is_event() method. These tests should pass.

I'm going to work on this for Hacktober. The requirements seem simple enough, but could you give me an example where there would be multiple dates returned in an array due to proposal by "differing sponsors"? Thanks!

Check out the Data/En/Us/February.php data file. In the getRecurringAdvancedConfigurationBasedEvents() function, 'Museum Advocacy Days' is on the first Monday and Tuesday of the February.

On a side note, I'm looking at refactoring the getRecurringAdvancedConfigurationBasedEvents() and getRecurringAdvancedConfigurationBasedHolidays() methods in a way that could affect your code (the issue is available at #6). I think that once this refactor is done, it would make the whenIs functionality easier to implement.

Let me know if you are still interested.

I've updated the data files to more easily accommodate this functionality.

  • Added recurringAdvancedConfigurationEvents and recurringAdvancedConfigurationHolidays properties. These can be used to quickly find if the event/holiday is in this month.
  • Moved the getRecurringAdvancedConfigurationBasedEvents() and getRecurringAdvancedConfigurationBasedHolidays() methods to the Month contract