Codebase list dfdatetime / 33e7215
New upstream version 20180510 Hilko Bengen 5 years ago
33 changed file(s) with 282 addition(s) and 335 deletion(s). Raw diff Collapse all Expand all
0 dfdatetime (20180509-1) unstable; urgency=low
0 dfdatetime (20180510-1) unstable; urgency=low
11
22 * Auto-generated
33
4 -- Log2Timeline <log2timeline-dev@googlegroups.com> Wed, 09 May 2018 07:07:06 +0200
4 -- Log2Timeline <log2timeline-dev@googlegroups.com> Thu, 10 May 2018 10:18:44 +0200
44 objects to preserve accuracy and precision.
55 """
66
7 __version__ = '20180509'
7 __version__ = '20180510'
122122
123123 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:06d}'.format(
124124 year, month, day_of_month, hours, minutes, seconds, microseconds)
125
126 def GetDate(self):
127 """Retrieves the date represented by the date and time values.
128
129 Returns:
130 tuple[int, int, int]: year, month, day of month or (None, None, None)
131 if the date and time values do not represent a date.
132 """
133 if self.timestamp is None:
134 return None, None, None
135
136 try:
137 number_of_days, _, _, _ = self._GetTimeValues(int(self.timestamp))
138 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
139
140 except ValueError:
141 return None, None, None
132132
133133 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:06d}'.format(
134134 year, month, day_of_month, hours, minutes, seconds, microseconds)
135
136 def GetDate(self):
137 """Retrieves the date represented by the date and time values.
138
139 Returns:
140 tuple[int, int, int]: year, month, day of month or (None, None, None)
141 if the date and time values do not represent a date.
142 """
143 if self.timestamp is None:
144 return None, None, None
145
146 try:
147 number_of_seconds = self.timestamp * definitions.SECONDS_PER_DAY
148 number_of_days, _, _, _ = self._GetTimeValues(int(number_of_seconds))
149 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
150
151 except ValueError:
152 return None, None, None
103103 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:06d}'.format(
104104 year, month, day_of_month, hours, minutes, seconds,
105105 self._microseconds)
106
107 def GetDate(self):
108 """Retrieves the date represented by the date and time values.
109
110 Returns:
111 tuple[int, int, int]: year, month, day of month or (None, None, None)
112 if the date and time values do not represent a date.
113 """
114 if self._number_of_seconds is None:
115 return None, None, None
116
117 try:
118 number_of_days, _, _, _ = self._GetTimeValues(self._number_of_seconds)
119 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
120
121 except ValueError:
122 return None, None, None
171171
172172 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}'.format(
173173 year, month, day_of_month, hours, minutes, seconds)
174
175 def GetDate(self):
176 """Retrieves the date represented by the date and time values.
177
178 Returns:
179 tuple[int, int, int]: year, month, day of month or (None, None, None)
180 if the date and time values do not represent a date.
181 """
182 if self._number_of_seconds is None:
183 return None, None, None
184
185 try:
186 number_of_days, _, _, _ = self._GetTimeValues(self._number_of_seconds)
187 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
188
189 except ValueError:
190 return None, None, None
124124
125125 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:07d}'.format(
126126 year, month, day_of_month, hours, minutes, seconds, remainder)
127
128 def GetDate(self):
129 """Retrieves the date represented by the date and time values.
130
131 Returns:
132 tuple[int, int, int]: year, month, day of month or (None, None, None)
133 if the date and time values do not represent a date.
134 """
135 if (self.timestamp is None or self.timestamp < 0 or
136 self.timestamp > self._UINT64_MAX):
137 return None, None, None
138
139 try:
140 timestamp, _ = divmod(self.timestamp, self._100NS_PER_SECOND)
141 number_of_days, _, _, _ = self._GetTimeValues(timestamp)
142 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
143
144 except ValueError:
145 return None, None, None
116116
117117 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}'.format(
118118 year, month, day_of_month, hours, minutes, seconds)
119
120 def GetDate(self):
121 """Retrieves the date represented by the date and time values.
122
123 Returns:
124 tuple[int, int, int]: year, month, day of month or (None, None, None)
125 if the date and time values do not represent a date.
126 """
127 if (self.timestamp is None or self.timestamp < 0 or
128 self.timestamp > self._UINT32_MAX):
129 return None, None, None
130
131 try:
132 number_of_days, _, _, _ = self._GetTimeValues(self.timestamp)
133 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
134
135 except ValueError:
136 return None, None, None
3131 self.year = year
3232
3333
34 class NormalizedTimeEpoch(DateTimeEpoch):
35 """dfDateTime normalized time epoch."""
36
37 def __init__(self):
38 """Initializes a dfDateTime normalized time epoch."""
39 super(NormalizedTimeEpoch, self).__init__(1970, 1, 1)
40
41
3442 class DateTimeValues(object):
3543 """Date and time values interface.
3644
4149 """
4250
4351 _DAYS_PER_MONTH = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
52
53 _EPOCH_NORMALIZED_TIME = NormalizedTimeEpoch()
4454
4555 _100NS_PER_SECOND = 10000000
4656 _100NS_PER_DECISECOND = 1000000
508518 of bounds.
509519 """
510520 if epoch_year < 0:
511 raise ValueError('Epoch year value out of bounds.')
521 raise ValueError('Epoch year value: {0:d} out of bounds.'.format(
522 epoch_year))
512523
513524 if epoch_month not in range(1, 13):
514 raise ValueError('Epoch month value out of bounds.')
525 raise ValueError('Epoch month value: {0:d} out of bounds.'.format(
526 epoch_month))
515527
516528 epoch_days_per_month = self._GetDaysPerMonth(epoch_year, epoch_month)
517529 if epoch_day_of_month < 1 or epoch_day_of_month > epoch_days_per_month:
518 raise ValueError('Epoch day of month value out of bounds.')
530 raise ValueError('Epoch day of month value: {0:d} out of bounds.'.format(
531 epoch_day_of_month))
519532
520533 before_epoch = number_of_days < 0
521534
769782 """Determines time values.
770783
771784 Args:
772 number_of_seconds (int): number of seconds.
785 number_of_seconds (int|decimal.Decimal): number of seconds.
773786
774787 Returns:
775788 tuple[int, int, int, int]: days, hours, minutes, seconds.
776789 """
790 number_of_seconds = int(number_of_seconds)
777791 number_of_minutes, seconds = divmod(number_of_seconds, 60)
778792 number_of_hours, minutes = divmod(number_of_minutes, 60)
779793 number_of_days, hours = divmod(number_of_hours, 24)
870884 str: date and time value formatted as: "YYYY-MM-DD hh:mm:ss.######"
871885 """
872886
873 @abc.abstractmethod
874887 def GetDate(self):
875888 """Retrieves the date represented by the date and time values.
876889
878891 tuple[int, int, int]: year, month, day of month or (None, None, None)
879892 if the date and time values do not represent a date.
880893 """
894 normalized_timestamp = self._GetNormalizedTimestamp()
895 if normalized_timestamp is None:
896 return None, None, None
897
898 number_of_days, _, _, _ = self._GetTimeValues(normalized_timestamp)
899
900 try:
901 return self._GetDateValuesWithEpoch(
902 number_of_days, self._EPOCH_NORMALIZED_TIME)
903
904 except ValueError:
905 return None, None, None
881906
882907 # TODO: remove this method when there is no more need for it in plaso.
883908 def GetPlasoTimestamp(self):
893918
894919 normalized_timestamp *= definitions.MICROSECONDS_PER_SECOND
895920 return int(round(normalized_timestamp))
921
922 def GetTimeOfDay(self):
923 """Retrieves the time of day represented by the date and time values.
924
925 Returns:
926 tuple[int, int, int]: hours, minutes, seconds or (None, None, None)
927 if the date and time values do not represent a time of day.
928 """
929 normalized_timestamp = self._GetNormalizedTimestamp()
930 if normalized_timestamp is None:
931 return None, None, None
932
933 _, hours, minutes, seconds = self._GetTimeValues(normalized_timestamp)
934 return hours, minutes, seconds
113113
114114 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:03d}'.format(
115115 year, month, day_of_month, hours, minutes, seconds, milliseconds)
116
117 def GetDate(self):
118 """Retrieves the date represented by the date and time values.
119
120 Returns:
121 tuple[int, int, int]: year, month, day of month or (None, None, None)
122 if the date and time values do not represent a date.
123 """
124 if (self.timestamp is None or self.timestamp < self._INT64_MIN or
125 self.timestamp > self._INT64_MAX):
126 return None, None, None
127
128 try:
129 timestamp, _ = divmod(self.timestamp, definitions.MILLISECONDS_PER_SECOND)
130 number_of_days, _, _, _ = self._GetTimeValues(timestamp)
131 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
132
133 except ValueError:
134 return None, None, None
129129
130130 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:06d}'.format(
131131 year, month, day_of_month, hours, minutes, seconds, microseconds)
132
133 def GetDate(self):
134 """Retrieves the date represented by the date and time values.
135
136 Returns:
137 tuple[int, int, int]: year, month, day of month or (None, None, None)
138 if the date and time values do not represent a date.
139 """
140 if self.timestamp is None:
141 return None, None, None
142
143 try:
144 timestamp = self.timestamp * definitions.SECONDS_PER_DAY
145 number_of_days, _, _, _ = self._GetTimeValues(int(timestamp))
146 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
147
148 except ValueError:
149 return None, None, None
106106
107107 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}'.format(
108108 year, month, day_of_month, hours, minutes, seconds)
109
110 def GetDate(self):
111 """Retrieves the date represented by the date and time values.
112
113 Returns:
114 tuple[int, int, int]: year, month, day of month or (None, None, None)
115 if the date and time values do not represent a date.
116 """
117 if self.timestamp is None:
118 return None, None, None
119
120 try:
121 number_of_days, _, _, _ = self._GetTimeValues(self.timestamp)
122 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
123
124 except ValueError:
125 return None, None, None
126109
127110
128111 class PosixTimeInMicroseconds(interface.DateTimeValues):
217200
218201 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:06d}'.format(
219202 year, month, day_of_month, hours, minutes, seconds, microseconds)
220
221 def GetDate(self):
222 """Retrieves the date represented by the date and time values.
223
224 Returns:
225 tuple[int, int, int]: year, month, day of month or (None, None, None)
226 if the date and time values do not represent a date.
227 """
228 if self.timestamp is None:
229 return None, None, None
230
231 try:
232 timestamp, _ = divmod(self.timestamp, definitions.MICROSECONDS_PER_SECOND)
233 number_of_days, _, _, _ = self._GetTimeValues(timestamp)
234 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
235
236 except ValueError:
237 return None, None, None
201201 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:01d}'.format(
202202 self.year, self.month, self.day_of_month, self.hours, self.minutes,
203203 self.seconds, self.deciseconds)
204
205 def GetDate(self):
206 """Retrieves the date represented by the date and time values.
207
208 Returns:
209 tuple[int, int, int]: year, month, day of month or (None, None, None)
210 if the date and time values do not represent a date.
211 """
212 if self._number_of_seconds is None:
213 return None, None, None
214
215 return self.year, self.month, self.day_of_month
180180 """
181181 return None, None
182182
183 def GetDate(self):
184 """Retrieves the date represented by the date and time values.
185
186 Returns:
187 tuple[int, int, int]: year, month, day of month or (None, None, None)
188 if the date and time values do not represent a date.
189 """
190 return None, None, None
191
192183 def GetPlasoTimestamp(self):
193184 """Retrieves a timestamp that is compatible with plaso.
194185
183183 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:03d}'.format(
184184 self.year, self.month, self.day_of_month, self.hours, self.minutes,
185185 self.seconds, self.milliseconds)
186
187 def GetDate(self):
188 """Retrieves the date represented by the date and time values.
189
190 Returns:
191 tuple[int, int, int]: year, month, day of month or (None, None, None)
192 if the date and time values do not represent a date.
193 """
194 if self._number_of_seconds is None:
195 return None, None, None
196
197 return self.year, self.month, self.day_of_month
409409 self._time_elements_tuple[2], self._time_elements_tuple[3],
410410 self._time_elements_tuple[4], self._time_elements_tuple[5])
411411
412 def GetDate(self):
413 """Retrieves the date represented by the date and time values.
414
415 Returns:
416 tuple[int, int, int]: year, month, day of month or (None, None, None)
417 if the date and time values do not represent a date.
418 """
419 if self._number_of_seconds is None:
420 return None, None, None
421
422 return (
423 self._time_elements_tuple[0], self._time_elements_tuple[1],
424 self._time_elements_tuple[2])
425
426412
427413 class TimeElementsWithFractionOfSecond(TimeElements):
428414 """Time elements with a fraction of second interface.
129129
130130 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:07d}'.format(
131131 year, month, day_of_month, hours, minutes, seconds, remainder)
132
133 def GetDate(self):
134 """Retrieves the date represented by the date and time values.
135
136 Returns:
137 tuple[int, int, int]: year, month, day of month or (None, None, None)
138 if the date and time values do not represent a date.
139 """
140 if (self.timestamp is None or self.timestamp < 0 or
141 self.timestamp > self._UINT60_MAX):
142 return None, None, None
143
144 try:
145 timestamp, _ = divmod(self.timestamp, self._100NS_PER_SECOND)
146 number_of_days, _, _, _ = self._GetTimeValues(timestamp)
147 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
148
149 except ValueError:
150 return None, None, None
118118
119119 return '{0:04d}-{1:02d}-{2:02d} {3:02d}:{4:02d}:{5:02d}.{6:06d}'.format(
120120 year, month, day_of_month, hours, minutes, seconds, microseconds)
121
122 def GetDate(self):
123 """Retrieves the date represented by the date and time values.
124
125 Returns:
126 tuple[int, int, int]: year, month, day of month or (None, None, None)
127 if the date and time values do not represent a date.
128 """
129 if (self.timestamp is None or self.timestamp < self._INT64_MIN or
130 self.timestamp > self._INT64_MAX):
131 return None, None, None
132
133 try:
134 timestamp, _ = divmod(self.timestamp, definitions.MICROSECONDS_PER_SECOND)
135 number_of_days, _, _, _ = self._GetTimeValues(timestamp)
136 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH)
137
138 except ValueError:
139 return None, None, None
4949
5050 expected_timestamp = 394934400.0
5151 cocoa_time_object.CopyFromDateTimeString('2013-07-08')
52 self.assertEqual(cocoa_time_object.timestamp, expected_timestamp)
52 self.assertEqual(cocoa_time_object._timestamp, expected_timestamp)
5353
5454 expected_timestamp = 395011845.0
5555 cocoa_time_object.CopyFromDateTimeString('2013-07-08 21:30:45')
56 self.assertEqual(cocoa_time_object.timestamp, expected_timestamp)
56 self.assertEqual(cocoa_time_object._timestamp, expected_timestamp)
5757
5858 expected_timestamp = 395011845.546875
5959 cocoa_time_object.CopyFromDateTimeString('2013-07-08 21:30:45.546875')
60 self.assertEqual(cocoa_time_object.timestamp, expected_timestamp)
60 self.assertEqual(cocoa_time_object._timestamp, expected_timestamp)
6161
6262 expected_timestamp = 395015445.546875
6363 cocoa_time_object.CopyFromDateTimeString('2013-07-08 21:30:45.546875-01:00')
64 self.assertEqual(cocoa_time_object.timestamp, expected_timestamp)
64 self.assertEqual(cocoa_time_object._timestamp, expected_timestamp)
6565
6666 expected_timestamp = 395008245.546875
6767 cocoa_time_object.CopyFromDateTimeString('2013-07-08 21:30:45.546875+01:00')
68 self.assertEqual(cocoa_time_object.timestamp, expected_timestamp)
68 self.assertEqual(cocoa_time_object._timestamp, expected_timestamp)
6969
7070 expected_timestamp = 86400.0
7171 cocoa_time_object.CopyFromDateTimeString('2001-01-02 00:00:00')
72 self.assertEqual(cocoa_time_object.timestamp, expected_timestamp)
72 self.assertEqual(cocoa_time_object._timestamp, expected_timestamp)
7373
7474 def testCopyToDateTimeString(self):
7575 """Tests the CopyToDateTimeString function."""
7777
7878 date_time_string = cocoa_time_object.CopyToDateTimeString()
7979 self.assertEqual(date_time_string, '2013-07-08 21:30:45.546875')
80
81 epoch_year = cocoa_time_object._EPOCH.year
82 cocoa_time_object._EPOCH.year = -1
83
84 with self.assertRaises(ValueError):
85 cocoa_time_object.CopyToDateTimeString()
86
87 cocoa_time_object._EPOCH.year = epoch_year
8088
8189 cocoa_time_object = cocoa_time.CocoaTime()
8290
8997
9098 date_tuple = cocoa_time_object.GetDate()
9199 self.assertEqual(date_tuple, (2013, 7, 8))
92
93 cocoa_time_object._EPOCH.year = -1
94
95 date_tuple = cocoa_time_object.GetDate()
96 self.assertEqual(date_tuple, (None, None, None))
97100
98101 cocoa_time_object = cocoa_time.CocoaTime()
99102
113116 micro_posix_timestamp = cocoa_time_object.GetPlasoTimestamp()
114117 self.assertIsNone(micro_posix_timestamp)
115118
119 def testGetTimeOfDay(self):
120 """Tests the GetTimeOfDay function."""
121 cocoa_time_object = cocoa_time.CocoaTime(timestamp=395011845.546875)
122
123 time_of_day_tuple = cocoa_time_object.GetTimeOfDay()
124 self.assertEqual(time_of_day_tuple, (21, 30, 45))
125
126 cocoa_time_object = cocoa_time.CocoaTime()
127
128 time_of_day_tuple = cocoa_time_object.GetTimeOfDay()
129 self.assertEqual(time_of_day_tuple, (None, None, None))
130
116131
117132 if __name__ == '__main__':
118133 unittest.main()
134134 date_tuple = delphi_date_time_object.GetDate()
135135 self.assertEqual(date_tuple, (2013, 6, 18))
136136
137 delphi_date_time_object._EPOCH.year = -1
138
139 date_tuple = delphi_date_time_object.GetDate()
140 self.assertEqual(date_tuple, (None, None, None))
141
142137 delphi_date_time_object = delphi_date_time.DelphiDateTime()
143138
144139 date_tuple = delphi_date_time_object.GetDate()
145140 self.assertEqual(date_tuple, (None, None, None))
146141
142 def testGetTimeOfDay(self):
143 """Tests the GetTimeOfDay function."""
144 delphi_date_time_object = delphi_date_time.DelphiDateTime(
145 timestamp=41443.8263953)
146
147 time_of_day_tuple = delphi_date_time_object.GetTimeOfDay()
148 self.assertEqual(time_of_day_tuple, (19, 50, 0))
149
150 delphi_date_time_object = delphi_date_time.DelphiDateTime()
151
152 time_of_day_tuple = delphi_date_time_object.GetTimeOfDay()
153 self.assertEqual(time_of_day_tuple, (None, None, None))
154
147155
148156 if __name__ == '__main__':
149157 unittest.main()
8989 date_tuple = fake_time_object.GetDate()
9090 self.assertEqual(date_tuple, (2010, 8, 12))
9191
92 fake_time_object._EPOCH.year = -1
92 fake_time_object = fake_time.FakeTime()
93 fake_time_object._number_of_seconds = None
9394
9495 date_tuple = fake_time_object.GetDate()
9596 self.assertEqual(date_tuple, (None, None, None))
9697
98 def testGetTimeOfDay(self):
99 """Tests the GetTimeOfDay function."""
97100 fake_time_object = fake_time.FakeTime()
101 fake_time_object.CopyFromDateTimeString('2010-08-12 21:06:31.546875')
98102
99 date_tuple = fake_time_object.GetDate()
100 self.assertEqual(date_tuple, (None, None, None))
103 time_of_day_tuple = fake_time_object.GetTimeOfDay()
104 self.assertEqual(time_of_day_tuple, (21, 6, 31))
105
106 fake_time_object = fake_time.FakeTime()
107 fake_time_object._number_of_seconds = None
108
109 time_of_day_tuple = fake_time_object.GetTimeOfDay()
110 self.assertEqual(time_of_day_tuple, (None, None, None))
101111
102112
103113 if __name__ == '__main__':
123123 date_tuple = fat_date_time_object.GetDate()
124124 self.assertEqual(date_tuple, (2010, 8, 12))
125125
126 fat_date_time_object._EPOCH.year = -1
127
128 date_tuple = fat_date_time_object.GetDate()
129 self.assertEqual(date_tuple, (None, None, None))
130
131126 fat_date_time_object = fat_date_time.FATDateTime()
132127
133128 date_tuple = fat_date_time_object.GetDate()
134129 self.assertEqual(date_tuple, (None, None, None))
135130
131 def testGetTimeOfDay(self):
132 """Tests the GetTimeOfDay function."""
133 fat_date_time_object = fat_date_time.FATDateTime(fat_date_time=0xa8d03d0c)
134
135 time_of_day_tuple = fat_date_time_object.GetTimeOfDay()
136 self.assertEqual(time_of_day_tuple, (21, 6, 32))
137
138 fat_date_time_object = fat_date_time.FATDateTime()
139
140 time_of_day_tuple = fat_date_time_object.GetTimeOfDay()
141 self.assertEqual(time_of_day_tuple, (None, None, None))
142
136143
137144 if __name__ == '__main__':
138145 unittest.main()
9797 date_tuple = filetime_object.GetDate()
9898 self.assertEqual(date_tuple, (2010, 8, 12))
9999
100 filetime_object._EPOCH.year = -1
101
102 date_tuple = filetime_object.GetDate()
103 self.assertEqual(date_tuple, (None, None, None))
104
105100 filetime_object = filetime.Filetime()
106101
107102 date_tuple = filetime_object.GetDate()
108103 self.assertEqual(date_tuple, (None, None, None))
109104
105 def testGetTimeOfDay(self):
106 """Tests the GetTimeOfDay function."""
107 filetime_object = filetime.Filetime(timestamp=0x01cb3a623d0a17ce)
108
109 time_of_day_tuple = filetime_object.GetTimeOfDay()
110 self.assertEqual(time_of_day_tuple, (21, 6, 31))
111
112 filetime_object = filetime.Filetime()
113
114 time_of_day_tuple = filetime_object.GetTimeOfDay()
115 self.assertEqual(time_of_day_tuple, (None, None, None))
116
110117
111118 if __name__ == '__main__':
112119 unittest.main()
102102 date_tuple = hfs_time_object.GetDate()
103103 self.assertEqual(date_tuple, (2013, 8, 1))
104104
105 hfs_time_object._EPOCH.year = -1
106
107 date_tuple = hfs_time_object.GetDate()
108 self.assertEqual(date_tuple, (None, None, None))
109
110105 hfs_time_object = hfs_time.HFSTime()
111106
112107 date_tuple = hfs_time_object.GetDate()
113108 self.assertEqual(date_tuple, (None, None, None))
114109
110 def testGetTimeOfDay(self):
111 """Tests the GetTimeOfDay function."""
112 hfs_time_object = hfs_time.HFSTime(timestamp=3458215528)
113
114 time_of_day_tuple = hfs_time_object.GetTimeOfDay()
115 self.assertEqual(time_of_day_tuple, (15, 25, 28))
116
117 hfs_time_object = hfs_time.HFSTime()
118
119 time_of_day_tuple = hfs_time_object.GetTimeOfDay()
120 self.assertEqual(time_of_day_tuple, (None, None, None))
121
115122
116123 if __name__ == '__main__':
117124 unittest.main()
8181 date_tuple = java_time_object.GetDate()
8282 self.assertEqual(date_tuple, (2010, 8, 12))
8383
84 java_time_object._EPOCH.year = -1
85
86 date_tuple = java_time_object.GetDate()
87 self.assertEqual(date_tuple, (None, None, None))
88
8984 java_time_object = java_time.JavaTime()
9085
9186 date_tuple = java_time_object.GetDate()
9287 self.assertEqual(date_tuple, (None, None, None))
9388
89 def testGetTimeOfDay(self):
90 """Tests the GetTimeOfDay function."""
91 java_time_object = java_time.JavaTime(timestamp=1281643591546)
92
93 time_of_day_tuple = java_time_object.GetTimeOfDay()
94 self.assertEqual(time_of_day_tuple, (20, 6, 31))
95
96 java_time_object = java_time.JavaTime()
97
98 time_of_day_tuple = java_time_object.GetTimeOfDay()
99 self.assertEqual(time_of_day_tuple, (None, None, None))
100
94101
95102 if __name__ == '__main__':
96103 unittest.main()
9999 date_tuple = ole_automation_date_object.GetDate()
100100 self.assertEqual(date_tuple, (2017, 11, 5))
101101
102 ole_automation_date_object._EPOCH.year = -1
103
104 date_tuple = ole_automation_date_object.GetDate()
105 self.assertEqual(date_tuple, (None, None, None))
106
107102 ole_automation_date_object = ole_automation_date.OLEAutomationDate()
108103
109104 date_tuple = ole_automation_date_object.GetDate()
110105 self.assertEqual(date_tuple, (None, None, None))
111106
107 def testGetTimeOfDay(self):
108 """Tests the GetTimeOfDay function."""
109 ole_automation_date_object = ole_automation_date.OLEAutomationDate(
110 timestamp=43044.480556)
111
112 time_of_day_tuple = ole_automation_date_object.GetTimeOfDay()
113 self.assertEqual(time_of_day_tuple, (11, 32, 0))
114
115 ole_automation_date_object = ole_automation_date.OLEAutomationDate()
116
117 time_of_day_tuple = ole_automation_date_object.GetTimeOfDay()
118 self.assertEqual(time_of_day_tuple, (None, None, None))
119
112120
113121 if __name__ == '__main__':
114122 unittest.main()
102102 date_tuple = posix_time_object.GetDate()
103103 self.assertEqual(date_tuple, (2010, 8, 12))
104104
105 posix_time_object._EPOCH.year = -1
105 posix_time_object = posix_time.PosixTime()
106106
107107 date_tuple = posix_time_object.GetDate()
108108 self.assertEqual(date_tuple, (None, None, None))
109109
110 posix_time_object = posix_time.PosixTime()
111
112 date_tuple = posix_time_object.GetDate()
113 self.assertEqual(date_tuple, (None, None, None))
110 def testGetTimeOfDay(self):
111 """Tests the GetTimeOfDay function."""
112 posix_time_object = posix_time.PosixTime(timestamp=1281643591)
113
114 time_of_day_tuple = posix_time_object.GetTimeOfDay()
115 self.assertEqual(time_of_day_tuple, (20, 6, 31))
116
117 posix_time_object = posix_time.PosixTime()
118
119 time_of_day_tuple = posix_time_object.GetTimeOfDay()
120 self.assertEqual(time_of_day_tuple, (None, None, None))
114121
115122
116123 class PosixTimeInMicrosecondsTest(unittest.TestCase):
205212 date_tuple = posix_time_object.GetDate()
206213 self.assertEqual(date_tuple, (2010, 8, 12))
207214
208 posix_time_object._EPOCH.year = -1
215 posix_time_object = posix_time.PosixTimeInMicroseconds()
209216
210217 date_tuple = posix_time_object.GetDate()
211218 self.assertEqual(date_tuple, (None, None, None))
212219
213 posix_time_object = posix_time.PosixTimeInMicroseconds()
214
215 date_tuple = posix_time_object.GetDate()
216 self.assertEqual(date_tuple, (None, None, None))
220 def testGetTimeOfDay(self):
221 """Tests the GetTimeOfDay function."""
222 posix_time_object = posix_time.PosixTimeInMicroseconds(
223 timestamp=1281643591546875)
224
225 time_of_day_tuple = posix_time_object.GetTimeOfDay()
226 self.assertEqual(time_of_day_tuple, (20, 6, 31))
227
228 posix_time_object = posix_time.PosixTimeInMicroseconds()
229
230 time_of_day_tuple = posix_time_object.GetTimeOfDay()
231 self.assertEqual(time_of_day_tuple, (None, None, None))
217232
218233
219234 if __name__ == '__main__':
228228 date_tuple = rfc2579_date_time_object.GetDate()
229229 self.assertEqual(date_tuple, (None, None, None))
230230
231 def testGetTimeOfDay(self):
232 """Tests the GetTimeOfDay function."""
233 rfc2579_date_time_object = rfc2579_date_time.RFC2579DateTime(
234 rfc2579_date_time_tuple=(2010, 8, 12, 20, 6, 31, 6, '+', 0, 0))
235
236 time_of_day_tuple = rfc2579_date_time_object.GetTimeOfDay()
237 self.assertEqual(time_of_day_tuple, (20, 6, 31))
238
239 rfc2579_date_time_object = rfc2579_date_time.RFC2579DateTime()
240
241 time_of_day_tuple = rfc2579_date_time_object.GetTimeOfDay()
242 self.assertEqual(time_of_day_tuple, (None, None, None))
243
231244
232245 if __name__ == '__main__':
233246 unittest.main()
9393 date_tuple = semantic_time_object.GetDate()
9494 self.assertEqual(date_tuple, (None, None, None))
9595
96 def testGetTimeOfDay(self):
97 """Tests the GetTimeOfDay function."""
98 semantic_time_object = semantic_time.SemanticTime()
99
100 time_of_day_tuple = semantic_time_object.GetTimeOfDay()
101 self.assertEqual(time_of_day_tuple, (None, None, None))
102
96103 def testGetPlasoTimestamp(self):
97104 """Tests the GetPlasoTimestamp function."""
98105 semantic_time_object = semantic_time.SemanticTime()
184184 date_tuple = systemtime_object.GetDate()
185185 self.assertEqual(date_tuple, (None, None, None))
186186
187 def testGetTimeOfDay(self):
188 """Tests the GetTimeOfDay function."""
189 systemtime_object = systemtime.Systemtime(
190 system_time_tuple=(2010, 8, 4, 12, 20, 6, 31, 142))
191
192 time_of_day_tuple = systemtime_object.GetTimeOfDay()
193 self.assertEqual(time_of_day_tuple, (20, 6, 31))
194
195 systemtime_object = systemtime.Systemtime()
196
197 time_of_day_tuple = systemtime_object.GetTimeOfDay()
198 self.assertEqual(time_of_day_tuple, (None, None, None))
199
187200
188201 if __name__ == '__main__':
189202 unittest.main()
484484 date_tuple = time_elements_object.GetDate()
485485 self.assertEqual(date_tuple, (None, None, None))
486486
487 def testGetTimeOfDay(self):
488 """Tests the GetTimeOfDay function."""
489 time_elements_object = time_elements.TimeElements(
490 time_elements_tuple=(2010, 8, 12, 20, 6, 31))
491
492 time_of_day_tuple = time_elements_object.GetTimeOfDay()
493 self.assertEqual(time_of_day_tuple, (20, 6, 31))
494
495 time_elements_object = time_elements.TimeElements()
496
497 time_of_day_tuple = time_elements_object.GetTimeOfDay()
498 self.assertEqual(time_of_day_tuple, (None, None, None))
499
487500
488501 class TimeElementsInMillisecondsTest(unittest.TestCase):
489502 """Tests for the time elements in milliseconds."""
739752 date_tuple = time_elements_object.GetDate()
740753 self.assertEqual(date_tuple, (None, None, None))
741754
755 def testGetTimeOfDay(self):
756 """Tests the GetTimeOfDay function."""
757 time_elements_object = time_elements.TimeElementsInMilliseconds(
758 time_elements_tuple=(2010, 8, 12, 20, 6, 31, 429))
759
760 time_of_day_tuple = time_elements_object.GetTimeOfDay()
761 self.assertEqual(time_of_day_tuple, (20, 6, 31))
762
763 time_elements_object = time_elements.TimeElementsInMilliseconds()
764
765 time_of_day_tuple = time_elements_object.GetTimeOfDay()
766 self.assertEqual(time_of_day_tuple, (None, None, None))
767
742768
743769 class TimeElementsInMicrosecondsTest(unittest.TestCase):
744770 """Tests for the time elements in microseconds."""
9941020 date_tuple = time_elements_object.GetDate()
9951021 self.assertEqual(date_tuple, (None, None, None))
9961022
1023 def testGetTimeOfDay(self):
1024 """Tests the GetTimeOfDay function."""
1025 time_elements_object = time_elements.TimeElementsInMicroseconds(
1026 time_elements_tuple=(2010, 8, 12, 20, 6, 31, 429876))
1027
1028 time_of_day_tuple = time_elements_object.GetTimeOfDay()
1029 self.assertEqual(time_of_day_tuple, (20, 6, 31))
1030
1031 time_elements_object = time_elements.TimeElementsInMicroseconds()
1032
1033 time_of_day_tuple = time_elements_object.GetTimeOfDay()
1034 self.assertEqual(time_of_day_tuple, (None, None, None))
1035
9971036
9981037 if __name__ == '__main__':
9991038 unittest.main()
128128 date_tuple = uuid_time_object.GetDate()
129129 self.assertEqual(date_tuple, (2012, 5, 16))
130130
131 uuid_time_object._EPOCH.year = -1
132
133 date_tuple = uuid_time_object.GetDate()
134 self.assertEqual(date_tuple, (None, None, None))
135
136131 uuid_time_object = uuid_time.UUIDTime()
137132
138133 date_tuple = uuid_time_object.GetDate()
139134 self.assertEqual(date_tuple, (None, None, None))
140135
136 def testGetTimeOfDay(self):
137 """Tests the GetTimeOfDay function."""
138 uuid_object = uuid.UUID('00911b54-9ef4-11e1-be53-525400123456')
139 uuid_time_object = uuid_time.UUIDTime(timestamp=uuid_object.time)
140
141 time_of_day_tuple = uuid_time_object.GetTimeOfDay()
142 self.assertEqual(time_of_day_tuple, (1, 11, 1))
143
144 uuid_time_object = uuid_time.UUIDTime()
145
146 time_of_day_tuple = uuid_time_object.GetTimeOfDay()
147 self.assertEqual(time_of_day_tuple, (None, None, None))
148
141149
142150 if __name__ == '__main__':
143151 unittest.main()
9797 date_tuple = webkit_time_object.GetDate()
9898 self.assertEqual(date_tuple, (2010, 8, 12))
9999
100 webkit_time_object._EPOCH.year = -1
101
102 date_tuple = webkit_time_object.GetDate()
103 self.assertEqual(date_tuple, (None, None, None))
104
105100 webkit_time_object = webkit_time.WebKitTime()
106101
107102 date_tuple = webkit_time_object.GetDate()
108103 self.assertEqual(date_tuple, (None, None, None))
109104
105 def testGetTimeOfDay(self):
106 """Tests the GetTimeOfDay function."""
107 webkit_time_object = webkit_time.WebKitTime(timestamp=12926120791546875)
108
109 time_of_day_tuple = webkit_time_object.GetTimeOfDay()
110 self.assertEqual(time_of_day_tuple, (21, 6, 31))
111
112 webkit_time_object = webkit_time.WebKitTime()
113
114 time_of_day_tuple = webkit_time_object.GetTimeOfDay()
115 self.assertEqual(time_of_day_tuple, (None, None, None))
116
110117
111118 if __name__ == '__main__':
112119 unittest.main()