class GEDCOM::Date

Constants

ABOUT
AFTER
BEFORE
BETWEEN
BIC
CALCULATED
CHILD
CLEARED
COMPLETED
DEAD
DNS
DNSCAN
ESTIMATED
FROM
FROMTO
INFANT
INTERPRETED
NONE

Calendar types

PRE1970
QUALIFIED
STILLBORN
SUBMITTED
TO
UNCLEARED

Public Class Methods

new( date_str, calendar=DateType::DEFAULT ) { |err_msg| ... } click to toggle source
Calls superclass method GEDCOM_DATE_PARSER::GEDDateValue::new
# File lib/gedcom_ruby/date.rb, line 161
def initialize ( date_str, calendar=DateType::DEFAULT )
  begin
    @date1 = DatePart.new
    @date2 = DatePart.new
    super(GEDCOM_DATE_PARSER::DateParser::GEDFNONE, @date1, @date2)
    GEDCOM_DATE_PARSER::DateParser.parse_gedcom_date( date_str, self, calendar )
 rescue GEDCOM_DATE_PARSER::DateParseException
    err_msg = "format error at '"
    if (@date1 && (@date1.flags & DatePart::NONSTANDARD))
      err_msg += @date1.data.to_s
    elsif (@date2)
      err_msg += @date2.data.to_s
    end
    err_msg += "'"
    if (block_given?)
      yield( err_msg )
    else
      raise DateFormatException, err_msg
    end
  end
end
safe_new( parm ) click to toggle source
# File lib/gedcom_ruby/date.rb, line 157
def Date.safe_new( parm )
  Date.new( parm ) { |errmsg| }
end

Public Instance Methods

<=>( d ) click to toggle source
# File lib/gedcom_ruby/date.rb, line 208
def <=>( d )
  if is_date? and d.is_date?
    rc = ( first <=> d.first )
    return rc unless rc == 0

    if is_range? and d.is_range?
      return ( last <=> d.last )
    elsif is_range?
      return 1
    elsif d.is_range?
      return -1
    end

    return 0
  elsif is_date?
    return -1
  elsif d.is_date?
    return 1
  end

  return format <=> d.format
end
first() click to toggle source
# File lib/gedcom_ruby/date.rb, line 187
def first
  @date1
end
format() click to toggle source
# File lib/gedcom_ruby/date.rb, line 183
def format
  @flags
end
is_date?() click to toggle source
# File lib/gedcom_ruby/date.rb, line 199
def is_date?
  (@flags & (NONE | ABOUT | CALCULATED | ESTIMATED | BEFORE | AFTER | BETWEEN \
        | FROM | TO | FROMTO | INTERPRETED)) != 0 ? false : true
end
is_range?() click to toggle source
# File lib/gedcom_ruby/date.rb, line 204
def is_range?
  (@flags & (BETWEEN | FROMTO)) != 0 ? true : false
end
last() click to toggle source
# File lib/gedcom_ruby/date.rb, line 191
def last
  @date2
end
to_s() click to toggle source
# File lib/gedcom_ruby/date.rb, line 195
def to_s
  GEDCOM_DATE_PARSER::DateParser.build_gedcom_date_string( self )
end