1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
from datetime import date
from gui.widgets.calendar import CalendarWidget
from ql.ast.nodes.expressions.literals.date_literal import DateNode
from ql.types.boolean import QLBoolean
from ql.types.type import QLType
class QLDate(QLType):
def __init__(self, day=1, month=1, year=1):
super(QLDate, self).__init__()
self.__day = int(day)
self.__month = int(month)
self.__year = int(year)
date(self.year, self.month, self.day)
@property
def day(self):
return self.__day
@property
def month(self):
return self.__month
@property
def year(self):
return self.__year
def __repr__(self):
return '{}-{}-{}'.format(self.day, self.month, self.year)
def __str__(self):
return '{}-{}-{}'.format(self.day, self.month, self.year)
def __eq__(self, other):
if isinstance(other, QLDate):
return QLBoolean(self.day == other.day and self.month == other.month and self.year == other.year)
return QLBoolean(False)
def __ne__(self, other):
return QLBoolean(not self == other)
def __lt__(self, other):
return QLBoolean(self.year < other.year or (self.month < other.month and self.year == other.year) or
(self.day < other.day and self.month == other.month and self.year == other.year))
def __gt__(self, other):
return QLBoolean(self.year > other.year or (self.month > other.month and self.year == other.year) or
(self.day > other.day and self.month == other.month and self.year == other.year))
def __le__(self, other):
return QLBoolean(self < other or self == other)
def __ge__(self, other):
return QLBoolean(self > other or self == other)
def get_json_value(self):
return {'day': self.day, 'month': self.month, 'year': self.year}
@staticmethod
def get_literal_node(value):
return DateNode(None, QLDate, value)
@staticmethod
def pyqt5_default_widget():
return CalendarWidget()
|