date_calculator 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/date_calculator.rb +24 -15
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9f2badcc4503f95385df829f86dab665aa6ad61c1dbe88dbdbab468db89a85f
4
- data.tar.gz: 413a9962d5e3d2c0d94a4d097f39dfd76613b592b5bd011c6b88791eeee7cb35
3
+ metadata.gz: d503d8c0f2da58a88a287a127a8eb792057aa8ebce9921198ad680fbfe51e097
4
+ data.tar.gz: 8120aca4f0b8dd9dc15f7ae666c24509fb3db25893aac9245cb09b368b293a0a
5
5
  SHA512:
6
- metadata.gz: 966a1cbe161af5106c669be0553c6c12ada343645dc6f5c12cc8eaa1b79e2e6ad6266b7f8aab6b0bcfed9d1d6a9bdad844ff23cbdf7602e84f2f07e36d4d877a
7
- data.tar.gz: 218013741e22cb680cc16e6f8a8ef45e09655a252db92f79981602858d6b796555e474236335ece380c2a2249bc55e8a9ec76bff3030b5fb136b5865efc1fd8d
6
+ metadata.gz: 07c7792748ec644a3757f48ea51ea59327a4b3fa6f6970458453a7bea26100dee40b9b25ce0afd91abf1d9a9cf6b33d4bd7c8afe0b99c8190e6d6ffa12b9a174
7
+ data.tar.gz: 92aeb5d26ce07f2a3664bde5ba73f9244d1421643630f8c98a273ba0f0147304c188e129a3a6ffe6e06494e97827e6f2d25e0390a9c5bc67d84f32e56c5ba360
@@ -1,29 +1,38 @@
1
1
  require 'date'
2
+
3
+ # Provides methods to calculate and manipulate dates.
2
4
  class DateCalculator
5
+ # Calculates the number of days between two dates.
6
+ #
7
+ # @param date1 [Date] The first date.
8
+ # @param date2 [Date] The second date.
9
+ # @return [Integer] The number of days between the two dates.
3
10
  def self.days_between(date1, date2)
4
- (date2 - date1).to_i
5
-
11
+ (date2 - date1).to_i # Computes the difference between the two dates and converts it to an integer.
6
12
  end
7
13
 
14
+ # Adds a specified number of days to a date.
15
+ #
16
+ # @param date [Date] The initial date.
17
+ # @param days [Integer] The number of days to add.
18
+ # @return [Date] The resulting date after adding the days.
8
19
  def self.add_days(date, days)
9
- days.times { date = date.next } # Itera o número de dias e usa .next para avançar a data
10
- date
20
+ days.times { date = date.next } # Iterates over the number of days and advances the date by one day at a time.
21
+ date # Returns the new date.
11
22
  end
12
23
 
24
+ # Checks if a given date is a weekend.
25
+ #
26
+ # @param date [Date] The date to check.
27
+ # @return [Boolean] True if the date is Saturday or Sunday, otherwise false.
13
28
  def self.is_weekend?(date)
14
- date.saturday? || date.sunday? # Verifica se é sábado ou domingo
29
+ date.saturday? || date.sunday? # Checks if the date is a Saturday or Sunday.
15
30
  end
16
31
 
32
+ # Returns the name of the current day of the week.
33
+ #
34
+ # @return [String] The name of the current day of the week (e.g., "Monday", "Tuesday").
17
35
  def self.what_day_is_it_today?
18
- Date.today.strftime("%A") # Retorna o nome do dia da semana (Ex: "Monday", "Tuesday")
36
+ Date.today.strftime("%A") # Returns the name of the current day of the week.
19
37
  end
20
-
21
38
  end
22
-
23
- date1 = Date.new(2023, 9, 10)
24
- date2 = Date.new(2023, 9, 17)
25
-
26
- puts DateCalculator.days_between(date1, date2) # Saída: 7
27
- puts DateCalculator.add_days(date1, 5) # Saída: 2023-09-15
28
- puts DateCalculator.is_weekend?(date1) # Saída: false
29
- puts DateCalculator.what_day_is_it_today? # Exemplo de saída: "Tuesday"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samns
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
62
+ version: '3.0'
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="