Skip to content
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

Dynamic first/last day of week and weekend days #380

Merged
merged 2 commits into from
Jun 13, 2015

Conversation

dani3l
Copy link
Contributor

@dani3l dani3l commented May 31, 2015

In Israel, week starts at Sunday and ends at Saturday, weekend days are Friday and Saturday
and many other countries has their own weekends and weird calendars.. so I think it might help others

Added:
protected static $weekStartsAt integer (use Carbon::DAYCONST)
protected static $weekEndsAt integer (use Carbon::DAYCONST)
protected static $weekendDays array (array of Carbon::DAYCONST)
public static function getWeekStartsAt()
public static function setWeekStartsAt($day)
public static function getWeekEndsAt()
public static function setWeekEndsAt($day)
public static function getWeekendDays()
public static function setWeekendDays($days)

Updated:
isWeekday() - to use !$this->isWeekend()
isWeekend() - to check if current day is in static::$weekendDays
startOfWeek() - to use static::$weekStartsAt
endOfWeek() - to use static::$weekEndsAt

dani3l added 2 commits May 31, 2015 13:51
In Israel, week starts at Sunday and ends at Saturday, weekend days are Friday and Saturday
and many other countries has their own weekends and weird calendars.. so I think it might help others

Added:
protected static $weekStartsAt integer (use Carbon::DAYCONST)
protected static $weekEndsAt integer (use Carbon::DAYCONST)
protected static $weekendDays array (array of Carbon::DAYCONST)
public static function getWeekStartsAt()
public static function setWeekStartsAt($day)
public static function getWeekEndsAt()
public static function setWeekEndsAt($day)
public static function getWeekendDays()
public static function setWeekendDays($days)

Updated:
isWeekday() - to use !$this->isWeekend()
isWeekend() - to check if current day is in static::$weekendDays
startOfWeek() - to use static::$weekStartsAt
endOfWeek() - to use static::$weekEndsAt
@dani3l
Copy link
Contributor Author

dani3l commented May 31, 2015

If you accept this one, the next level would be to automate it with locales
Set the first/last days of week and weekend days inside a locale file and set them when calling setLocale() but then you'd have to use the full xx_XX locale convention to make it perfect

briannesbitt added a commit that referenced this pull request Jun 13, 2015
Dynamic first/last day of week and weekend days
@briannesbitt briannesbitt merged commit 32eeb8d into briannesbitt:master Jun 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants