Class: Qt::DateTime

Inherits:
Base show all
Defined in:
lib/Qt/qtruby4.rb

Instance Method Summary collapse

Methods inherited from Base

#%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #QCOMPARE, #QEXPECT_FAIL, #QFAIL, #QSKIP, #QTEST, #QVERIFY, #QVERIFY2, #QWARN, #^, ancestors, #is_a?, #methods, private_slots, #protected_methods, #public_methods, q_classinfo, q_signal, q_slot, signals, #singleton_methods, slots, #|, #~

Constructor Details

#initialize(*args) ⇒ DateTime

Returns a new instance of DateTime.



691
692
693
694
695
696
697
698
699
700
701
702
703
# File 'lib/Qt/qtruby4.rb', line 691

def initialize(*args)
  if args.size == 1 && args[0].class.name == "DateTime"
    return super(  Qt::Date.new(args[0].year, args[0].month, args[0].day),
            Qt::Time.new(args[0].hour, args[0].min, args[0].sec) )
  elsif args.size == 1 && args[0].class.name == "Time"
    result = super(  Qt::Date.new(args[0].year, args[0].month, args[0].day),
            Qt::Time.new(args[0].hour, args[0].min, args[0].sec, args[0].usec / 1000) )
    result.timeSpec = (args[0].utc? ? Qt::UTC : Qt::LocalTime)
    return result
  else
    return super(*args)
  end
end

Instance Method Details

#inspectObject



715
716
717
718
# File 'lib/Qt/qtruby4.rb', line 715

def inspect
  str = super
  str.sub(/>$/, " %s>" % toString)
end

#pretty_print(pp) ⇒ Object



720
721
722
723
# File 'lib/Qt/qtruby4.rb', line 720

def pretty_print(pp)
  str = to_s
  pp.text str.sub(/>$/, " %s>" % toString)
end

#to_timeObject



705
706
707
708
709
710
711
712
713
# File 'lib/Qt/qtruby4.rb', line 705

def to_time
  if timeSpec == Qt::UTC
    return ::Time.utc(  date.year, date.month, date.day,
              time.hour, time.minute, time.second, time.msec * 1000 )
  else
    return ::Time.local(  date.year, date.month, date.day,
                time.hour, time.minute, time.second, time.msec * 1000 )
  end
end