Sha256: f93530e014a234b026985d0e86ad5d54b95ad5fa4596bf427658807785d67be9

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

require 'odbc'

module ODBC
  class TimeStamp
    alias_method :old_to_s, :to_s

    def ==( pal )
      return to_s.index( pal.to_s ) == 0
    end

    def to_s
      datetime = old_to_s
      date, time, fraction = datetime.split(" ")

      fraction_text = (fraction == '0') ? '' : ".#{fraction}"
      return "#{date} #{time}#{fraction_text}"
    end

    def self.from_date(date)
      return ODBC::TimeStamp.new(date.strftime('%Y-%m-%d 0:0:0.000'))
    end

    def self.from_time(time)
      return ODBC::TimeStamp.new(time.strftime('%Y-%m-%d %H:%M:%S.000'))
    end

    def inspect
      "#{old_to_s.split[0]} #{old_to_s.split[1]}"
    end

  end

  class Error
    def error_code
      start_index = to_s =~ /(\()/
      end_index = to_s =~ /(\))/
      end_index -= 1
      return to_s.slice( (start_index + 1 ), (end_index - start_index ) ).to_i
    end

    def error_message
      return to_s.split( /\]/ ).last.rstrip
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
marjoree-0.0.9 ./lib/marjoree/odbc.rb