Skip to content

Commit 5878eed

Browse files
author
Rick Hull
committed
cleanup
1 parent 6092e16 commit 5878eed

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/compsci/date.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class InvalidDay < RuntimeError; end
1313
include Comparable
1414

1515
#
16-
# Gregorian Calendar Leap Years
16+
# Leap Years
1717
#
1818

1919
# this is the crux of the Gregorian calendar
@@ -28,7 +28,7 @@ def self.leap_days(year)
2828
end
2929

3030
#
31-
# Gregorian Calendar Definitions
31+
# Definitions
3232
#
3333

3434
# define month lengths
@@ -51,16 +51,17 @@ def self.leap_days(year)
5151
LEAP_YEAR_DAYS = ANNUAL_DAYS + 1 # 366
5252
CUMULATIVE_DAYS.freeze
5353

54-
MEAN_ANNUAL_DAYS = 365.2425
55-
MEAN_MONTH_DAYS = MEAN_ANNUAL_DAYS / NUM_MONTHS
56-
5754
# implementation considerations
5855
MIN_Y, MIN_M, MIN_D = 1, 1, 1
5956
MAX_Y, MAX_M, MAX_D = 9999, NUM_MONTHS, MON31
60-
EPOCH_Y, EPOCH_M, EPOCH_D = 1, 1, 1
57+
58+
# currently unused
59+
# EPOCH_Y, EPOCH_M, EPOCH_D = 1, 1, 1
60+
# MEAN_ANNUAL_DAYS = 365.2425
61+
# MEAN_MONTH_DAYS = MEAN_ANNUAL_DAYS / NUM_MONTHS
6162

6263
#
63-
# Gregorian Calendar Functions
64+
# Functions
6465
#
6566

6667
# perform lookup by month number and year, one-indexed, with leap days
@@ -76,6 +77,7 @@ def self.guess_month(days)
7677
(days / MON30 + 1).clamp(MIN_M, MAX_M)
7778
end
7879

80+
# how many days have elapsed before the beginning of the month?
7981
# perform lookup by month number and year, one-indexed, with leap days
8082
def self.cumulative_days(month, year)
8183
raise(InvalidMonth, month.inspect) unless (1..12).cover?(month)
@@ -130,7 +132,7 @@ def self.year_count(days)
130132
end
131133

132134
#
133-
# Gregorian Calendar Coversions (days since Epoch, 0001-01-01)
135+
# Coversions (days since Epoch, 0001-01-01)
134136
#
135137

136138
# convert date (as year, month, day) to days since epoch
@@ -149,7 +151,7 @@ def self.from_days(days)
149151
end
150152

151153
#
152-
# Gregorian Month Names
154+
# Month Names
153155
#
154156

155157
# define lookup of month name by month number, zero-indexed
@@ -174,7 +176,7 @@ def self.month_name(number)
174176
end
175177

176178
#
177-
# Gregorian Calendar Instances
179+
# Date Instances
178180
#
179181

180182
attr_reader :day_count

0 commit comments

Comments
 (0)