Class: CalendarChina::Date

Inherits:
Object
  • Object
show all
Includes:
Methods, DateHelper
Defined in:
lib/calendar_china.rb

Overview

China’s Calendar. For more details, see the calendar_china/methods.rb

NOTE: need to update the lib/data/xxxx.json on time. retrieve these json file from github.com/NateScarlet/holiday-cn, and thanks to NateScarlet

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DateHelper

#adjust_date, #current_date, #current_year, #format_date

Methods included from Methods

#is_holiday?, #is_rest?, #is_workday?, #next_workday

Constructor Details

#initialize(year = current_year, date = current_date) ⇒ Date

By default, initialize current year and date. you also can specify the fields. Below is some examples for usage: ccd = CalendarChina::Date.new(“2020”, “2020-01-01”) ccd.is_holiday? => true ccd.is_rest? => true ccd.is_workday? => false ccd.next_workday => :days=>0



27
28
29
30
# File 'lib/calendar_china.rb', line 27

def initialize(year = current_year, date = current_date)
  @china_year = year
  @china_date = adjust_date(date)
end

Instance Attribute Details

#china_dateObject

Returns the value of attribute china_date.



18
19
20
# File 'lib/calendar_china.rb', line 18

def china_date
  @china_date
end

#china_yearObject

Returns the value of attribute china_year.



18
19
20
# File 'lib/calendar_china.rb', line 18

def china_year
  @china_year
end