Class: ODBC::TimeStamp

Inherits:
Object
  • Object
show all
Defined in:
lib/marjoree/odbc.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_date(date) ⇒ Object



19
20
21
# File 'lib/marjoree/odbc.rb', line 19

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

.from_time(time) ⇒ Object



23
24
25
# File 'lib/marjoree/odbc.rb', line 23

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

Instance Method Details

#==(pal) ⇒ Object



7
8
9
# File 'lib/marjoree/odbc.rb', line 7

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

#inspectObject



27
28
29
# File 'lib/marjoree/odbc.rb', line 27

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

#old_to_sObject



5
# File 'lib/marjoree/odbc.rb', line 5

alias_method :old_to_s, :to_s

#to_sObject



11
12
13
14
15
16
17
# File 'lib/marjoree/odbc.rb', line 11

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

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