dateoperations 0.0.2 → 0.1.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: cfd90d8293a749a6fd266508ca029f366a0b08e0
4
- data.tar.gz: 74dcfa904f08b166e10dd3c1d294d83b6082ba2e
2
+ SHA256:
3
+ metadata.gz: 1ca32965a4b54020b096084bd73f2d0e542c0c9e7288d7d0dd6267d762db2367
4
+ data.tar.gz: 321751ae85afd3f0234f3e0002e40cd6dab106e4891c6a2ba43dad82dcc7c817
5
5
  SHA512:
6
- metadata.gz: f9cb3fc95767df4055e7c7c942e3fb334bd171a5810f694d511a7006c4e6c5b487d8e15d6b78f596726ef6659db0ac273a4bc36c896b7107ad9c566e8188f6d9
7
- data.tar.gz: 4eb2a8cb59bba7d0906fe79e36f02091e0b712ab03189b2cfa88ffd9bf4cb89bd4dffea27180f3be622835736cec5916eb071d2cfd87e42e77315a1bbd1b2314
6
+ metadata.gz: c36d511c38a24be4f80ef6d19f70a0e8ceb59e9a1e8c1129ef5972703b0ec9c6b5ce32edc1f94e83080f7974ac14af4f6f0bc34b138be8d0dc6a3163de5b0f82
7
+ data.tar.gz: bee5cf9446913ea2dd5528441d7cd218a086f460e3eba70d4b8d35cde535f6ade097a8004f037bdcae61ab0001764df3c4c56d04713ea764500fc18c19c98bf3
data/README.md CHANGED
@@ -1,4 +1,9 @@
1
1
  # DateOperations
2
+
3
+ [![](https://codescene.io/projects/5634/status.svg) Get more details at **codescene.io**.](https://codescene.io/projects/5634/jobs/latest-successful/results)
4
+
5
+ ## Overview
6
+
2
7
  Different date operations, primarily around business days; based on the [Holidays Gem](https://github.com/holidays/holidays).
3
8
 
4
9
  ## Synopsis
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # 0.1.0 - Anhebung der Ruby-Mindestversion auf >= 3.4.0, Aktualisierung des holidays-Gems und Code-Refactoring
4
+ class DateOperations
5
+ VERSION = '0.1.0'
6
+ end
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
  require 'holidays'
5
+ require_relative 'dateoperations/version'
3
6
 
4
7
  ##
5
8
  # Different date operations, primarily around business days, based on the Holidays[https://github.com/holidays/holidays] Gem.
6
- # - Home[]https://github.com/msc01/dateoperations
9
+ # - Home[https://github.com/msc01/dateoperations]
7
10
  # - Documentation[http://dateoperations.schwarze-web.de/DateOperations.html]
8
11
  class DateOperations
9
12
  @country = :de
@@ -16,30 +19,26 @@ class DateOperations
16
19
  attr_accessor :country
17
20
  end
18
21
 
19
- # Returns an array with dates for the "week days" (= Monday to Friday) between a given start and end date.
22
+ # Returns an array with dates for the week days (Monday to Friday) between a given start and end date.
20
23
  def self.week_days_between(start_date, end_date)
21
24
  week_day_nbrs = (1..5)
22
25
  (start_date..end_date).select { |w| week_day_nbrs.include?(w.wday) }
23
26
  end
24
27
 
25
- # returns the number of "week days" (= Monday to Friday) between a given start and end date.
28
+ # returns the number of week days (Monday to Friday) between a given start and end date.
26
29
  def self.number_of_week_days_between(start_date, end_date)
27
30
  week_days = week_days_between(start_date, end_date)
28
31
  week_days.length
29
32
  end
30
33
 
31
- # Returns an array with dates
32
- # for the "business days" = "week days" (= Monday to Friday)
33
- # without <tt>holidays</tt>
34
+ # Returns an array with dates for the business days (week days (Monday to Friday) without holidays).
34
35
  # between a given start and end date.
35
36
  def self.business_days_between(start_date, end_date)
36
37
  week_days = week_days_between(start_date, end_date)
37
38
  week_days.reject { |b| holiday?(b) }
38
39
  end
39
40
 
40
- # Returns the number of "business days"
41
- # = "week days" (= Monday to Friday)
42
- # without <tt>holidays</tt>
41
+ # Returns the number of business days (week days (Monday to Friday) without holidays).
43
42
  # between a given start and end date.
44
43
  def self.number_of_business_days_between(start_date, end_date)
45
44
  business_days = business_days_between(start_date, end_date)
@@ -51,9 +50,8 @@ class DateOperations
51
50
  date.saturday? || date.sunday?
52
51
  end
53
52
 
54
- # Checks whether a given date is a holiday based on the calendar for the respective <tt>country</tt>.
53
+ # Checks whether a given date is a holiday based on the calendar for the respective country.
55
54
  def self.holiday?(date)
56
- return false if Holidays.on(date, DateOperations.country, :informal).empty?
57
- true
55
+ Holidays.on(date, DateOperations.country, :informal).any?
58
56
  end
59
57
  end
metadata CHANGED
@@ -1,29 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dateoperations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Schwarze
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2016-06-21 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: holidays
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - '='
16
+ - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 4.3.0
18
+ version: '11'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - '='
23
+ - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 4.3.0
25
+ version: '11'
27
26
  description: Simple date operations to determine weekends, holidays, and esp. business
28
27
  days. Based on the Holidays Gem.
29
28
  email: michael@schwarze-web.de
@@ -34,11 +33,12 @@ files:
34
33
  - LICENSE.txt
35
34
  - README.md
36
35
  - lib/dateoperations.rb
36
+ - lib/dateoperations/version.rb
37
37
  homepage: https://github.com/msc01/dateoperations
38
38
  licenses:
39
39
  - MIT
40
- metadata: {}
41
- post_install_message:
40
+ metadata:
41
+ rubygems_mfa_required: 'true'
42
42
  rdoc_options: []
43
43
  require_paths:
44
44
  - lib
@@ -46,16 +46,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '0'
49
+ version: 3.4.0
50
50
  required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  requirements: []
56
- rubyforge_project:
57
- rubygems_version: 2.5.1
58
- signing_key:
56
+ rubygems_version: 4.0.8
59
57
  specification_version: 4
60
58
  summary: Date Operations
61
59
  test_files: []