business_time 0.9.3 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5fe356eb4f4e620e3f3db2aa9242df1c63213500
4
- data.tar.gz: d1f662a4f576662e3f6d140970d5b2191016fda8
2
+ SHA256:
3
+ metadata.gz: cb1621dd19416fb58fba1a2dcaff32e65542e29e18d09fdea0a9d7dca621f132
4
+ data.tar.gz: ef8f7a0816e6e1df588a3e14424894b397df07e4217718594dd109c6c2bc4aaf
5
5
  SHA512:
6
- metadata.gz: 86434d31fbf26aa3372510db883266643431a449fa2980cee43e9d34198c140a560d0606d41911aa0a47e030b373eeba0442f38dad07c36a5b5113a811c97213
7
- data.tar.gz: 5c1ae7866418a21538030ba2129698eaafb2016b5d715cd2c13e31e1739b8732ff625af6f87e48e98bbe697ea06005d74c35bfab7c8610b306f7ba7c9d0121b5
6
+ metadata.gz: fa4d68c497aa80d701692dc5182837603e8cd66cdef810298fb727f29b65d5c92b22da9b3ce5a6f1c5e4533551b3de1b4a7591931c1f68dc3c0e1dde8b62dd66
7
+ data.tar.gz: a62611ad7ac045fa795a98eaca9fed77a86725bc09a87e4941290ad2f7bda3a3851756fc22d609b802fadfc122440945f58f6bc240140bcd6bc19c0b21820ecf
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = business_time
2
2
 
3
- {<img src="https://secure.travis-ci.org/bokmann/business_time.png" />}[http://travis-ci.org/bokmann/business_time]
3
+ {<img src="https://github.com/bokmann/business_time/workflows/CI/badge.svg" />}[https://github.com/bokmann/business_time/actions?query=workflow%3ACI]
4
4
 
5
5
  ActiveSupport gives us some great helpers so we can do things like:
6
6
 
@@ -220,4 +220,4 @@ I'm proud of the work in this gem; the stability is a big part of that. This ge
220
220
 
221
221
  == Copyright
222
222
 
223
- Copyright (c) 2010-2017 bokmann. See LICENSE for details.
223
+ Copyright (c) 2010-2021 bokmann. See LICENSE for details.
@@ -37,6 +37,9 @@ module BusinessTime
37
37
  end
38
38
 
39
39
  def calculate_after(time, days)
40
+ if (time.is_a?(Time) || time.is_a?(DateTime)) && !time.workday?
41
+ time = Time.beginning_of_workday(time)
42
+ end
40
43
  while days > 0 || !time.workday?
41
44
  days -= 1 if time.workday?
42
45
  time += 1.day
@@ -50,6 +53,9 @@ module BusinessTime
50
53
  end
51
54
 
52
55
  def calculate_before(time, days)
56
+ if (time.is_a?(Time) || time.is_a?(DateTime)) && !time.workday?
57
+ time = Time.beginning_of_workday(time)
58
+ end
53
59
  while days > 0 || !time.workday?
54
60
  days -= 1 if time.workday?
55
61
  time -= 1.day
@@ -80,23 +80,7 @@ module BusinessTime
80
80
  end
81
81
  end
82
82
 
83
- # You can set this yourself, either by the load method below, or
84
- # by saying
85
- # BusinessTime::Config.beginning_of_workday = "8:30 am"
86
- # someplace in the initializers of your application.
87
- threadsafe_cattr_reader :beginning_of_workday
88
-
89
- # You can set this yourself, either by the load method below, or
90
- # by saying
91
- # BusinessTime::Config.end_of_workday = "5:30 pm"
92
- # someplace in the initializers of your application.
93
- threadsafe_cattr_reader :end_of_workday
94
-
95
- # You can set this yourself, either by the load method below, or
96
- # by saying
97
- # BusinessTime::Config.work_week = [:sun, :mon, :tue, :wed, :thu]
98
- # someplace in the initializers of your application.
99
- threadsafe_cattr_accessor :work_week
83
+ threadsafe_cattr_reader :work_week
100
84
 
101
85
  # You can set this yourself, either by the load method below, or
102
86
  # by saying
@@ -118,6 +102,10 @@ module BusinessTime
118
102
  threadsafe_cattr_accessor :fiscal_month_offset
119
103
 
120
104
  class << self
105
+ # You can set this yourself, either by the load method below, or
106
+ # by saying
107
+ # BusinessTime::Config.end_of_workday = "5:30 pm"
108
+ # someplace in the initializers of your application.
121
109
  def end_of_workday(day=nil)
122
110
  if day
123
111
  wday = work_hours[int_to_wday(day.wday)]
@@ -127,6 +115,10 @@ module BusinessTime
127
115
  end
128
116
  end
129
117
 
118
+ # You can set this yourself, either by the load method below, or
119
+ # by saying
120
+ # BusinessTime::Config.beginning_of_workday = "8:30 am"
121
+ # someplace in the initializers of your application.
130
122
  def beginning_of_workday(day=nil)
131
123
  if day
132
124
  wday = work_hours[int_to_wday(day.wday)]
@@ -136,6 +128,10 @@ module BusinessTime
136
128
  end
137
129
  end
138
130
 
131
+ # You can set this yourself, either by the load method below, or
132
+ # by saying
133
+ # BusinessTime::Config.work_week = [:sun, :mon, :tue, :wed, :thu]
134
+ # someplace in the initializers of your application.
139
135
  def work_week=(days)
140
136
  config[:work_week] = days
141
137
  self._weekdays = nil
@@ -1,3 +1,3 @@
1
1
  module BusinessTime
2
- VERSION = "0.9.3"
2
+ VERSION = "0.10.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: business_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bokmann
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-04 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sorted_set
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +136,7 @@ homepage: https://github.com/bokmann/business_time
122
136
  licenses:
123
137
  - MIT
124
138
  metadata: {}
125
- post_install_message:
139
+ post_install_message:
126
140
  rdoc_options: []
127
141
  require_paths:
128
142
  - lib
@@ -137,9 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
153
  requirements: []
140
- rubyforge_project:
141
- rubygems_version: 2.6.13
142
- signing_key:
154
+ rubygems_version: 3.2.11
155
+ signing_key:
143
156
  specification_version: 4
144
157
  summary: Support for doing time math in business hours and days
145
158
  test_files: []