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
Grouping level This must be one of year, month, day, hour, minute or second. @return [String]
Day (1-31) @return [Integer]
Hour (0..23) @return [Integer]
Minute (0..59( @return [Integer]
Month (1..12) @return [Integer]
Second (0..59) @return [Integer]
Year (4 digits) @return [Integer|String]
Public Class Methods
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
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
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
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
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
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
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
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
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