class Qiflib::Date

Instances of this class represent a date from within a qif file, such as ‘D5/24/94’.

Attributes

ccyymmdd[RW]
dd[RW]
mm[RW]
string_value[RW]
year[RW]
year_mm[RW]
yy[RW]

Public Class Methods

new(string_value='') click to toggle source
# File lib/qiflib_date.rb, line 11
def initialize(string_value='')
  @cc, @yy, @mm, @dd = '00', '00', '00', '00'
  @string_value = "#{string_value}".tr('D','')
  tokens = @string_value.split('/')
  if (tokens && tokens.size > 2)
    m   = tokens[0].to_i
    d   = tokens[1].to_i
    y   = tokens[2].to_i
    @yy = tokens[2]
    y < 50 ? @cc = "20" : @cc = "19"
    m < 10 ? @mm = "0#{m}" : @mm = "#{m}"
    d < 10 ? @dd = "0#{d}" : @dd = "#{d}"
  end
  @ccyymmdd = "#{@cc}#{@yy}-#{@mm}-#{@dd}"
  @year     = "#{@cc}#{@yy}"
  @year_mm  = "#{@cc}#{@yy}-#{@mm}"
end

Public Instance Methods

to_s() click to toggle source
# File lib/qiflib_date.rb, line 29
def to_s
  @ccyymmdd
end