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.



654
655
656
657
658
659
660
661
662
663
664
665
666
# File 'lib/Qt/qtruby4.rb', line 654

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



678
679
680
681
# File 'lib/Qt/qtruby4.rb', line 678

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

#pretty_print(pp) ⇒ Object



683
684
685
686
# File 'lib/Qt/qtruby4.rb', line 683

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

#to_timeObject



668
669
670
671
672
673
674
675
676
# File 'lib/Qt/qtruby4.rb', line 668

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