1 from datetime import datetime
2
4 """
5 Help class to operate dates and times
6 """
7
9 """
10 constructor
11 date parameter can be suplied
12 """
13 if (date == None):
14 self.fromDateTime(datetime.now())
15 else:
16 if (isinstance(date,str) == True):
17 self.fromString(date)
18 elif (isinstance(date, datetime) == True):
19 self.fromDateTime(date)
20
21
23 """
24 inits the object with another BasicFipaDateTime class
25 """
26 self.calendar = dt
27
29 """
30 loads the date and time from a string
31 """
32 if string != None and string != "":
33
34
35 year = int(string[0:4])
36 month = int(string[4:6])
37 day = int(string[6:8])
38
39 hour = int(string[9:11])
40 minute = int(string[11:13])
41 second = int(string[13:15])
42 milli = int(string[15:18])
43
44 self.calendar = datetime(year,month,day,hour,minute,second,milli)
45
46 return True
47 else:
48 return False
49
50
51
52
54 return self.calendar.year
55
58
60 return self.calendar.month
61
63 self.calendar = datetime(self.calendar.year,month, self.calendar.day,self.calendar.hour,self.calendar.minute,self.calendar.second,self.calendar.microsecond,self.calendar.tzinfo)
64
66 return self.calendar.day
67
69 self.calendar = datetime(self.calendar.year,self.calendar.month,day,self.calendar.hour,self.calendar.minute,self.calendar.second,self.calendar.microsecond,self.calendar.tzinfo)
70
72 return self.calendar.hour
73
75 self.calendar = datetime(self.calendar.year,self.calendar.month, self.calendar.day,hour,self.calendar.minute,self.calendar.second,self.calendar.microsecond,self.calendar.tzinfo)
76
78 return self.calendar.minute
79
81 self.calendar = datetime(self.calendar.year,self.calendar.month, self.calendar.day,self.calendar.hour,minute,self.calendar.second,self.calendar.microsecond,self.calendar.tzinfo)
82
84 return self.calendar.second
85
87 self.calendar = datetime(self.calendar.year,self.calendar.month, self.calendar.day,self.calendar.hour,self.calendar.minute,second,self.calendar.microsecond,self.calendar.tzinfo)
88
90 return self.calendar.microsecond
91
93 self.calendar = datetime(self.calendar.year,self.calendar.month, self.calendar.day,self.calendar.hour,self.calendar.minute,self.calendat.second,microsecond,self.calendar.tzinfo)
94
96 return self.calendar.tzinfo
97
101
103 res = str(val)
104 while len(res) < size:
105 res = '0' + res
106 return str(res)
107
117
119 """
120 returns a printable version of the object
121 """
122 return self.__str__()
123
125 """
126 returns a printable version of the object
127 """
128 return self.__str__()
129