class Axlsx::Filters::DateGroupItem

This collection is used to express a group of dates or times which are used in an AutoFilter criteria. Values are always written in the calendar type of the first date encountered in the filter range, so that all subsequent dates, even when formatted or represented by other calendar types, can be correctly compared for the purposes of filtering.

Constants

DATE_TIME_GROUPING

Allowed date time groupings

Attributes

date_time_grouping[R]

Grouping level This must be one of year, month, day, hour, minute or second. @return [String]

day[R]

Day (1-31) @return [Integer]

hour[R]

Hour (0..23) @return [Integer]

minute[R]

Minute (0..59( @return [Integer]

month[R]

Month (1..12) @return [Integer]

second[R]

Second (0..59) @return [Integer]

year[R]

Year (4 digits) @return [Integer|String]

Public Class Methods

new(options={}) click to toggle source

Creates a new DateGroupItem @param [Hash] options A hash of options to use when instanciating the object @option [String] date_time_grouping the part of the date this filter should apply for grouping @option [Integer|String] year @see year @option [Integer] month @see month @option [Integer] day @see day @option [Integer] hour @see hour @option [Integer] minute @see minute @option [Integer] second @see second

# File lib/axlsx/workbook/worksheet/auto_filter/filters.rb, line 148
def initialize(options={})
  raise ArgumentError,  "You must specify a year for date time grouping" unless options[:year]
  raise ArgumentError, "You must specify a date_time_grouping when creating a DateGroupItem for auto filter" unless options[:date_time_grouping]
  parse_options options
end

Public Instance Methods

date_time_grouping=(grouping) click to toggle source

The date time grouping for this filter.

# File lib/axlsx/workbook/worksheet/auto_filter/filters.rb, line 232
def date_time_grouping=(grouping)
  RestrictionValidator.validate 'DateGroupItem.date_time_grouping', DATE_TIME_GROUPING, grouping.to_s
  @date_time_grouping = grouping.to_s
end
day=(value) click to toggle source

The day value for the date group item This must be between 1 and 31 @note no attempt is made to ensure the date value is valid for any given month

# File lib/axlsx/workbook/worksheet/auto_filter/filters.rb, line 205
def day=(value)
  RangeValidator.validate "DateGroupItem.day", 0, 31, value
  @day = value
end
hour=(value) click to toggle source

The hour value for the date group item # this must be between 0 and 23

# File lib/axlsx/workbook/worksheet/auto_filter/filters.rb, line 212
def hour=(value)
  RangeValidator.validate "DateGroupItem.hour", 0, 23, value
  @hour = value
end
minute=(value) click to toggle source

The minute value for the date group item This must be between 0 and 59

# File lib/axlsx/workbook/worksheet/auto_filter/filters.rb, line 219
def minute=(value)
  RangeValidator.validate "DateGroupItem.minute", 0, 59, value
  @minute = value
end
month=(value) click to toggle source

The month value for the date group item This must be between 1 and 12

# File lib/axlsx/workbook/worksheet/auto_filter/filters.rb, line 197
def month=(value)
  RangeValidator.validate "DateGroupItem.month", 0, 12, value
  @month = value
end
second=(value) click to toggle source

The second value for the date group item This must be between 0 and 59

# File lib/axlsx/workbook/worksheet/auto_filter/filters.rb, line 226
def second=(value)
  RangeValidator.validate "DateGroupItem.second", 0, 59, value
  @second = value
end
to_xml_string(str = '') click to toggle source

Serialize the object to xml @param [String] str The string object this serialization will be concatenated to.

# File lib/axlsx/workbook/worksheet/auto_filter/filters.rb, line 239
def to_xml_string(str = '')
  str << '<dateGroupItem '
  serialized_attributes str
  str << '/>'
end
year=(value) click to toggle source

The year value for the date group item This must be a four digit value

# File lib/axlsx/workbook/worksheet/auto_filter/filters.rb, line 190
def year=(value)
  RegexValidator.validate "DateGroupItem.year", /\d{4}/, value
  @year = value
end