-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
Add Singapore Public Holiday #94
Conversation
e0af794
to
182d6d4
Compare
I added REPLACEMENT feature when holiday is in Sunday |
182d6d4
to
24ccc25
Compare
Refactor replacement for Sunday holiday. Trying to think if it can implemented in the Holiday class but it seems that not all countries are doing the same process |
24ccc25
to
db23fee
Compare
I added the Deepavali Holiday using the moon phases. I used the "solaris/php-moon-phase" package to determine the phases of the moon. I based the date using the Indian Calendar in Kartik month |
e84ea1b
to
53d268d
Compare
Rebased to the latest main branch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a ChineseCalendar trait you can use: https://github.com/spatie/holidays/blob/main/src/Calendars/ChineseCalendar.php
For the Islamic & Indian calendars, could you use the same reusable approach as the ChineseCalendar trait? Thanks!
src/Countries/Singapore.php
Outdated
} | ||
|
||
/** @return array<string, string|CarbonImmutable> */ | ||
protected function replacementForSunday(string $name, int $year, string $input, int $addDays = 0): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this name & code more readable, so it's immediately obvious what it does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will review on this.
src/Countries/Singapore.php
Outdated
return (int) $hijriYear; | ||
} | ||
|
||
protected function chineseCalendar(string $input, int $year): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could use the ChineseCalendar trait
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will review on this.
src/Countries/Singapore.php
Outdated
} | ||
|
||
|
||
protected function getIslamicFormatter(): IntlDateFormatter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thecaliskan would you want to help reviewing the Islamic part? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nielsvanpach I will prepare a script and check it when I am available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @thecaliskan and @Nielsvanpach I have updated my changes in this branch. You may want to check
Thanks
53d268d
to
a5a74e3
Compare
Hi @Nielsvanpach, I have added the Islamic Calendar and Indian Calendar and I used the Chinese Calendar Trait. Regarding Deepavali Date, I didn't include this holiday in the Indian Calendar. I was thinking of adding it but I'm not sure if all countries celebrating the Deepavali Date is the same with Singapore. For the replacement function I renamed it to " |
a5a74e3
to
42c322c
Compare
Hi @Nielsvanpach , I'm planning to add a function to check if the holiday is a regular or a replacement holiday. |
42c322c
to
db70b65
Compare
Updated the composer.json file to fix the conflict |
Hi @Nielsvanpach , is there anything that I need to add on this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
I'm not sure if the IslamicCalendar gives proper results, as it was previously stated this is different from country to country.
"nesbot/carbon": "^2.72.1|^3.0" | ||
"nesbot/carbon": "^2.72.1|^3.0", | ||
"ext-calendar": "*", | ||
"solaris/php-moon-phase": "^2.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
solaris/php-moon-phase can be removed, I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I used the moon phase for deepavali event as this holiday is based on the moon phases
* | ||
* @return array<string, string|CarbonImmutable> | ||
*/ | ||
protected function replaceHolidayFallsOnSunday(string $holidayName, int $year, string $input, int $moveDays = 1): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could use the Observable trait for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will convert this to Observable trait
Dear contributor, because this pull request seems to be inactive for quite some time now, I've automatically closed it. If you feel this pull request deserves some attention from my human colleagues feel free to reopen it. |
Singapore Holidays
Changes
Holidays
. If falls onSunday
,Monday
will be the replacement. ForChinese New Year
, if the Day is Sunday and Monday then theTuesday
will be the replacement forSunday
.IntlDateFormatter
for accurate calendar calculationsChinese Calendar
to get the Chinese New Year and Vesak Day datesIslamic Calendar
to get the Hari Raya Puasa and Hari Raya Haji datesIndian Calendar
to get the Kartik month which is 8th month of the Indian Calendar and 10th month of the Gregorian Calendar.solaris/php-moon-phase
for accurate computation of moon phases. Especially forDeepavali
holiday, as this holiday is based on moon appearanceAdditional Notes
solaris/php-moon-phase
extension is required for this addition. It is referenced in thecomposer.json
file.References:
Singapore's Ministry of Manpower to reference the Holidays in Singapore
MOM Gov Public Holiday
Deepavali date is based on the appearance of the moon.
Deepavali is subject to change
Chinese Calendar
Islamic Calendar
Indian Calendar