summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activity.lua4
-rw-r--r--spec/activity_spec.lua18
2 files changed, 11 insertions, 11 deletions
diff --git a/activity.lua b/activity.lua
index 1be6e93..1d1ef8e 100644
--- a/activity.lua
+++ b/activity.lua
@@ -1,7 +1,7 @@
local activity = {}
-function activity.days (year)
+function activity.days_in (year)
if year % 4 ~= 0 or year % 100 == 0 and year % 400 ~= 0 then
return 365
end
@@ -53,7 +53,7 @@ function activity.generate_table (year)
local rows = ""
local weekdays = {"", "Mon", "", "Wed", "", "Fri", ""}
local start_from = activity.first_week_day(year)
- local end_at = (start_from + activity.days(year) - 1) % 7
+ local end_at = (start_from + activity.days_in(year) - 1) % 7
for index, weekday in pairs(weekdays) do
rows = rows .. row(weekday, index >= start_from, index <= end_at)
end
diff --git a/spec/activity_spec.lua b/spec/activity_spec.lua
index 08160fa..074be22 100644
--- a/spec/activity_spec.lua
+++ b/spec/activity_spec.lua
@@ -2,21 +2,21 @@ local activity = require "activity"
describe("Days in a year", function()
it("should support regular years", function()
- assert.are.equal(365, activity.days(1970))
- assert.are.equal(365, activity.days(2001))
+ assert.are.equal(365, activity.days_in(1970))
+ assert.are.equal(365, activity.days_in(2001))
end)
it("should support lean years", function()
- assert.are.equal(366, activity.days(2004))
- assert.are.equal(366, activity.days(1980))
+ assert.are.equal(366, activity.days_in(2004))
+ assert.are.equal(366, activity.days_in(1980))
end)
it("should support *00 years", function()
- assert.are.equal(366, activity.days(2000))
- assert.are.equal(365, activity.days(2100))
- assert.are.equal(365, activity.days(2200))
- assert.are.equal(365, activity.days(2300))
- assert.are.equal(366, activity.days(2400))
+ assert.are.equal(366, activity.days_in(2000))
+ assert.are.equal(365, activity.days_in(2100))
+ assert.are.equal(365, activity.days_in(2200))
+ assert.are.equal(365, activity.days_in(2300))
+ assert.are.equal(366, activity.days_in(2400))
end)
end)