Skip to content

Conversation

xentixar
Copy link

@xentixar xentixar commented Sep 6, 2025

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.

@kamil-tekiela
Copy link
Member

kamil-tekiela commented Sep 9, 2025

Why do you consider the weekend to be Saturday and Sunday? Why not other days? How is this determined? see https://en.wikipedia.org/wiki/Workweek_and_weekend#History

@iluuu1994 iluuu1994 added the RFC label Oct 6, 2025
@iluuu1994
Copy link
Member

Given the feedback, this probably requires a discussion on the mailing list and/or an RFC. Marking accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants