Coder Social home page Coder Social logo

Comments (7)

ppeble avatar ppeble commented on July 4, 2024 2

This feature has been merged, I will get a release out that contains the additional functionality sometime this week.

from holidays.

ppeble avatar ppeble commented on July 4, 2024 1

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.

brentdodell avatar brentdodell commented on July 4, 2024 1

Great to hear! Thanks @ptrimble & @ttwo32.

from holidays.

ppeble avatar ppeble commented on July 4, 2024

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.

brentdodell avatar brentdodell commented on July 4, 2024

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.

ppeble avatar ppeble commented on July 4, 2024

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.

ttwo32 avatar ttwo32 commented on July 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.