Skip to content

Commit

Permalink
Cylical dependency resolution for Time, Date, and Calculations.
Browse files Browse the repository at this point in the history
  • Loading branch information
amirrajan committed Feb 19, 2018
1 parent 68b6b99 commit e848067
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
4 changes: 1 addition & 3 deletions app/lib/date.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Date
# defined?(Object)
defined?(Object)

def self.gregorian_leap?(year)
if year % 400 == 0
Expand Down Expand Up @@ -86,8 +86,6 @@ def acts_like_date?
true
end

# include DateAndTime::Calculations

class << self
attr_accessor :beginning_of_week_default

Expand Down
16 changes: 8 additions & 8 deletions app/lib/date_and_time.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module DateAndTime
module Calculations
# defined?(Date) # Ensure that `Date` is compiled before this class.
# defined?(Time) # Ensure that `Time` is compiled before this class.
defined?(Date) # Ensure that `Date` is compiled before this class.
defined?(Time) # Ensure that `Time` is compiled before this class.

DAYS_INTO_WEEK = {
:monday => 0,
Expand Down Expand Up @@ -232,10 +232,10 @@ def days_span(day)
end
end

# class Date
# include DateAndTime::Calculations
# end
class Date
include DateAndTime::Calculations
end

# class Time
# include DateAndTime::Calculations
# end
class Time
include DateAndTime::Calculations
end
4 changes: 1 addition & 3 deletions app/lib/time.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Time
# defined?(Object)
defined?(Object)

def to_date
Date.new(year, month, day)
Expand Down Expand Up @@ -32,8 +32,6 @@ def acts_like_time?
true
end

# include DateAndTime::Calculations

COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

class << self
Expand Down

0 comments on commit e848067

Please sign in to comment.