From fb1297a0cd84fde95c565178d0d223258d1c2bee Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 31 Aug 2023 23:16:59 +0200 Subject: Renamed activity.days_in(year) --- activity.lua | 4 ++-- spec/activity_spec.lua | 18 +++++++++--------- 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) -- cgit v1.1