Commit dcd042d9 authored by Jean Felder's avatar Jean Felder Committed by Jean Felder

GLib overrides: Add support for DateTime.compare

Closes: #334
parent 060dbc6b
......@@ -876,3 +876,21 @@ deprecated_attr("GLib", "glib_version",
pyglib_version = version_info
__all__.append('pyglib_version')
deprecated_attr("GLib", "pyglib_version", "gi.version_info")
@override
class DateTime(GLib.DateTime):
@classmethod
def compare(cls, dt1, dt2):
difference = GLib.DateTime.difference(dt1, dt2)
if (difference < 0):
return -1
elif (difference > 0):
return 1
else:
return 0
__all__.append('DateTime')
......@@ -121,6 +121,14 @@ def test_iochannel_win32():
os.remove(fn)
def test_datetime_compare():
dt100 = GLib.DateTime.new_from_unix_utc(100)
dt1000 = GLib.DateTime.new_from_unix_utc(1000)
assert GLib.DateTime.compare(dt100, dt1000) == -1
assert GLib.DateTime.compare(dt1000, dt100) == 1
assert GLib.DateTime.compare(dt100, dt100) == 0
class TestGVariant(unittest.TestCase):
def test_create_simple(self):
variant = GLib.Variant('i', 42)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment