README.md in working_hours-1.0.2 vs README.md in working_hours-1.0.3
- old
+ new
@@ -3,11 +3,11 @@
[](https://travis-ci.org/Intrepidd/working_hours)
A modern ruby gem allowing to do time calculation with working hours.
Compatible and tested with:
-- Ruby `2.0`, `2.1`
+- Ruby `2.0`, `2.1`, JRuby `1.7`
- ActiveSupport `3.2.x`, `4.0.x` and `4.1.x`
## Installation
Gemfile:
@@ -34,10 +34,12 @@
# Start from custom Date or Time
Date.new(2014, 12, 31) + 8.working.days # => Mon, 12 Jan 2015
Time.utc(2014, 8, 4, 8, 32) - 4.working.hours # => 2014-08-01 13:00:00
# Compute working days between two dates
+friday = Date.new(2014, 10, 17)
+monday = Date.new(2014, 10, 20)
friday.working_days_until(monday) # => 1
# Time is considered at end of day, so:
# - friday to saturday = 0 working days
# - sunday to monday = 1 working days
@@ -49,10 +51,16 @@
# Know if a day is worked
Date.new(2014, 12, 28).working_day? # => false
# Know if a time is worked
Time.utc(2014, 8, 4, 7, 16).in_working_hours? # => false
+
+# Advance to next working time
+WorkingHours.advance_to_working_time(Time.utc(2014, 8, 4, 7, 16)) # => Mon, 04 Aug 2014 09:00:00 UTC +00:00
+
+# Return to previous working time
+WorkingHours.return_to_working_time(Time.utc(2014, 8, 4, 7, 16)) # => Fri, 01 Aug 2014 17:00:00 UTC +00:00
```
## Configuration
The working hours configuration is thread local and consists of a hash defining working periods for each day, a time zone and a list of days off.
@@ -94,10 +102,12 @@
# Start from custom Date or Time
WorkingHours::Duration.new(8, :days).since(Date.new(2014, 12, 31)) # => Mon, 12 Jan 2015
WorkingHours::Duration.new(4, :hours).until(Time.utc(2014, 8, 4, 8, 32)) # => 2014-08-01 13:00:00
# Compute working days between two dates
+friday = Date.new(2014, 10, 17)
+monday = Date.new(2014, 10, 20)
WorkingHours.working_days_between(friday, monday) # => 1
# Time is considered at end of day, so:
# - friday to saturday = 0 working days
# - sunday to monday = 1 working days
@@ -121,15 +131,15 @@
require 'working_hours/module'
class Order
include WorkingHours
- def shipping_date_estimate
- Duration.new(2, :days).since(paiement_received_at)
+ def shipping_date_estibmate
+ Duration.new(2, :days).since(payment_received_at)
end
- def paiement_delay
- working_days_between(created_at, paiement_received_at)
+ def payment_delay
+ working_days_between(created_at, payment_received_at)
end
end
```
## Timezones