Comments (7)
This feature has been merged, I will get a release out that contains the additional functionality sometime this week.
from holidays.
I'm going to write it here even though I wrote it on the PR as well but: @ttwo32's PR looks great! I think it almost exactly satisfies the use case that @brentdodell wrote out above. Once @ttwo32 and I come to an agreement on a few small nitpicks I had I'll merge it and get this out in a minor point release.
from holidays.
Great to hear! Thanks @ptrimble & @ttwo32.
from holidays.
Hi @brentdodell, no, unfortunately there is no use case along those lines that I am aware of. I would be happy to treat this as a feature request, though, if you wouldn't mind expanding a bit on the actual use case details. It doesn't seem like it would be incredibly difficult.
Can you outline a few concrete examples? One or two is fine. That way I can see exactly what you expect and we can discuss how I can implement it.
from holidays.
This is kind of what I had in mind...feel free to tweak if need-be.
def self.next(holiday_count, regions, from = Date.today)
end
holiday_count
is the number of holidays to return
regions
is an array of the regions
from
is the date from which to find the next holiday_count
number of holidays.
In my mind, from
should be an optional param, defaulted to Date.today
.
I originally had an inclusive
param, to determine whether or not to include holidays that fall on the from
date, or only show those that come after it. On second thought I decided that it would be just as easy, if not easier, to pass in Date.today + 1
for from
if needing to exclude today's holidays and start with tomorrow's.
Get next 3 US holidays (including informal) after (and including) today:
Date.today
=> Tue, 23 Feb 2016
regions = [:us, :informal]
Holidays.next(3, regions)
=> [{:name => "St. Patrick's Day",...},
{:name => "Good Friday",...},
{:name => "Easter Sunday",...}]
Get next 4 US holidays after (and including) December 24th (it goes ahead and rolls to the new year)
regions = [:us]
from = Date.civil(2016, 12, 24)
Holidays.next(4, regions, from)
=> [{:name => "Christmas Day",...},
{:name => "New Year's Day",...},
{:name => "Martin Luther King, Jr. Day",...},
{:name => "President's Day",...}]
What are your thoughts?
from holidays.
I really like this. I think this is a great idea. Let me take a stab at it soon, I think this is definitely doable.
Thanks for the suggestion! It's now on my official to-do list. 😄
from holidays.
Hi @ptrimble @brentdodell .
I have sent PR next_holiday method.
Maybe , this method matches your thoughts.
Please review my PR #191.
from holidays.
Related Issues (20)
- DatesDriverBuilder does not work properly with Lunar calendar
- 4 day UK Bank Holiday in 2022 HOT 4
- Release a new version to allow this gem to be used with Ruby 3.0 HOT 4
- Get a list of all holidays possible for a given region
- Manage Belgium parent region HOT 1
- I have an issue with columbus day HOT 1
- Version Bump Request HOT 4
- Korea's new year get next year's new year
- Islamic holidays
- Día de los Muertos is not listed
- How to prevent stacked observed holidays HOT 1
- GB Substitute Days over Christmas and New Year HOT 1
- Liberation Day, Region NL
- Queen Elizabeth II passing Bank Holiday HOT 10
- Loading custom holidays clears all the provided definitions? HOT 1
- Strange behavoir with end_of_month HOT 2
- Feast of San Giusto for Trieste, Italy should be on 3rd November
- Shouldn't July 3, 2026 be "Independence Day (observed)" in the US? HOT 2
- Project updates HOT 10
- Hanukkah does not appear in list of holidays HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from holidays.