[php-src] PR #19734: Add isWeekend() and isWeekday() methods to DateTime classes
| From: | xentixar | Date: | Sat, 06 Sep 2025 09:22:44 +0000 |
| Subject: | [php-src] PR #19734: Add isWeekend() and isWeekday() methods to DateTime classes | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-33110@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/19734
Author: xentixar
This PR adds two new methods to DateTime and DateTimeImmutable classes:
- isWeekend(): Checks if the date falls on a weekend (Saturday or Sunday)
- isWeekday(): Checks if the date falls on a weekday (Monday through Friday)
The methods are also declared in DateTimeInterface, ensuring they're available across all
implementing classes.
Implementation includes:
- Helper functions in timelib library
- Method implementations for DateTime and DateTimeImmutable
- Proper interface declarations
- Test cases for basic functionality and inheritance
These methods provide a convenient way to check if a date is a weekend or weekday without manually
checking the day of week.