Giter VIP home page Giter VIP logo

business's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

business's Issues

wrong documentation for loading extra calendars on version 2

Hello in the doc to load extra calendars we are supposed to do
Business::Calendar.load_paths("lib/calendars") # your_project/lib/calendars/ contains bacs.yml
Business::Calendar.load("bacs")
the resulting error is wrong number of arguments (given 1, expected 0)
load_paths is an attr_accessor accepting an array so the doc should be
Business::Calendar.load_paths = [Rails.root.join("lib/calendars")] # your_project/lib/calendars/ contains bacs.yml
Business::Calendar.load("bacs")

Wrong number of business days in June 2015

Loving the gem - however I noticed that for some reason June 2015 (with the BST timezone) reports incorrect business days.

calendar = Business::Calendar.new(working_days: %w( mon tue wed thu fri ))
start_date = Date.parse("23 June 2015")
end_date = Date.parse("30 June 2015")
calendar.business_days_between(start_date, end_date) #=> 5

(start_date..end_date).to_a.select {|d| calendar.business_day?(d)}.size #=> 6

Any ideas what's wrong? Is it only me that sees this?

How to update a yml file and how to use it into my own lib/data folder

Hi:

Amazing gem you have created. It's working really good. I have two questions, so I hope you can help me:

1.- Where can I find the yml files that comes along with the gem so I can edit them?
2.- How can I use my own .yml file on my lib/data directory?

Thanks for your answer.!

roll_forward and roll_backward not working

Version: 1.16.0
Ruby: 2.6.3p62
Rails: 5.0.1

The roll_forward and roll_backward methods are returning the current date instead of previous and next business day

 current_date = Date.today.in_time_zone('Australia/Melbourne')
      calendar = Business::Calendar.new(
        working_days: %w[mon tue wed thu fri],
        holidays: HolidayList.holidays(current_date)
      )

      p calendar
      p calendar.roll_forward(Time.now.in_time_zone('Australia/Melbourne').to_date)

Expected:

#<Business::Calendar:0x00007f8933f20d00 @extra_working_dates=[], @working_days=["mon", "tue", "wed", "thu", "fri"], @holidays=[Wed, 25 Dec 2019, Thu, 26 Dec 2019]>
Fri, 06 Dec 2019

Received:

#<Business::Calendar:0x00007f8933f20d00 @extra_working_dates=[], @working_days=["mon", "tue", "wed", "thu", "fri"], @holidays=[Wed, 25 Dec 2019, Thu, 26 Dec 2019]>
Thu, 05 Dec 2019

Define clearer aliases for `#roll_forward` and `#roll_backward`

Define these instance methods of Business::Calendar:

  • earliest_business_date_on_or_after – alias for roll_forward
  • latest_business_date_on_or_before – alias for roll_backward

While these names are more verbose, my team agrees that they are easier to understand.

Part of the problem with the current names roll_forward and roll_backward is that the imperative verb “roll” makes the methods sound like they will mutate the passed date, though they do not. (It’s good that they do not.)

Define these new names as aliases instead of renaming the existing methods to preserve backwards compatibility.

Document `next_business_day` and `previous_business_day` in the README

#next_business_day and #previous_business_day are useful public methods of Business::Calendar:

# Roll forward to the next business day regardless of whether the given
# date is a business day or not.
def next_business_day(date)
loop do
date += day_interval_for(date)
break date if business_day?(date)
end
end
# Roll backward to the previous business day regardless of whether the given
# date is a business day or not.
def previous_business_day(date)
loop do
date -= day_interval_for(date)
break date if business_day?(date)
end
end

The README’s “Business day arithmetic” section does not document those methods. It should.

Where I think this documentation belongs in that section of the README:

  • Business day arithmetic
    • ⚠️ next_business_day – documentation needed
    • ⚠️ previous_business_day – documentation needed
    • add_business_days
    • subtract_business_days
    • roll_forward
    • roll_backward
    • business_days_between

Rename module/namespace

I realize this would be a disruptive change, but I have to maintain my own fork with the Business module renamed to BusinessDay because my application has a class named Business. Probably not a common problem, but I think a best practice would be to establish a namespace that's more specific and descriptive, and as such less likely to conflict with other code. Happy to submit a PR if there's any interest in pursuing this.

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.