Sha256: 2c5c2932008eb4784cf4601ca167b8ec62b5248b5ee4db6b4e675997635e2d37
Contents?: true
Size: 1.07 KB
Versions: 11
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true require_relative './support/unit' module TimeBoss class Calendar class Day < Support::Unit def initialize(calendar, start_date) super(calendar, start_date, start_date) end # Get a simple representation of this day. # @return [String] (e.g. "2020-08-03") def name start_date.to_s end # Get a "pretty" representation of this day. # @return [String] (e.g. "August 3, 2020") def title start_date.strftime('%B %-d, %Y') end alias_method :to_s, :name # Get the index of this day within its containing year. # @return [Integer] def index @_index ||= (start_date - year.start_date).to_i + 1 end # Get the year number for this day. # @return [Integer] (e.g. 2020) def year_index @_year_index ||= year.year_index end private def down self.class.new(calendar, start_date - 1.day) end def up self.class.new(calendar, start_date + 1.day) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems