README.md in working_hours-1.0.3 vs README.md in working_hours-1.0.4
- old
+ new
@@ -69,21 +69,34 @@
# Configure working hours
WorkingHours::Config.working_hours = {
:tue => {'09:00' => '12:00', '13:00' => '17:00'},
:wed => {'09:00' => '12:00', '13:00' => '17:00'},
:thu => {'09:00' => '12:00', '13:00' => '17:00'},
- :fri => {'09:00' => '12:00', '13:00' => '17:00'},
- :sat => {'10:00' => '15:00'}
+ :fri => {'09:00' => '12:00', '13:00' => '17:05:30'},
+ :sat => {'19:00' => '24:00'}
}
# Configure timezone (uses activesupport, defaults to UTC)
WorkingHours::Config.time_zone = 'Paris'
# Configure holidays
WorkingHours::Config.holidays = [Date.new(2014, 12, 31)]
```
+Alternatively, you can apply a particular config in a block with the ``with_config`` method :
+
+```ruby
+WorkingHours::Config.with_config(working_hours: {mon:{'09:00' => '18:00'}}, holidays: [], time_zone: 'Paris') do
+ # Intense calculations
+end
+```
+``with_config`` uses keyword arguments, you can pass all or some of the supported arguments :
+- ``working_hours``
+- ``holidays``
+- ``time_zone``
+
+
## No core extensions / monkey patching
Core extensions (monkey patching to add methods on Time, Date, Numbers, etc.) are handy but not appreciated by everyone. WorkingHours can also be used **without any monkey patching**:
```ruby
@@ -131,11 +144,11 @@
require 'working_hours/module'
class Order
include WorkingHours
- def shipping_date_estibmate
+ def shipping_date_estimate
Duration.new(2, :days).since(payment_received_at)
end
def payment_delay
working_days_between(created_at, payment_received_at)
@@ -143,14 +156,16 @@
end
```
## Timezones
-This gem uses a simple but efficient approach in dealing with timezones. When you define your working hours **you have to choose** a timezone associated with it (in the config example, the working hours are in Paris time). Then, any time used in calcultation will be converted to this timezone first, so you don't have to worry if your times are local or UTC as long as they are correct :)
+This gem uses a simple but efficient approach in dealing with timezones. When you define your working hours **you have to choose** a timezone associated with it (in the config example, the working hours are in Paris time). Then, any time used in calculation will be converted to this timezone first, so you don't have to worry if your times are local or UTC as long as they are correct :)
## Alternatives
There is a gem called [business_time](https://github.com/bokmann/business_time) already available to do this kind of computation and it was of great help to us. But we decided to start another one because business_time is suffering from a few [bugs](https://github.com/bokmann/business_time/pull/84) and [inconsistencies](https://github.com/bokmann/business_time/issues/50). It also lacks essential features to us (like working minutes computation).
+
+Another gem called [biz](https://github.com/zendesk/biz) was released after working_hours to bring some alternative.
## Contributing
1. Fork it ( http://github.com/intrepidd/working_hours/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)