LEFT | RIGHT |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """FAT date time implementation.""" | 2 """FAT date time implementation.""" |
3 | 3 |
4 from __future__ import unicode_literals | 4 from __future__ import unicode_literals |
5 | 5 |
6 import decimal | 6 import decimal |
7 | 7 |
8 from dfdatetime import definitions | 8 from dfdatetime import definitions |
9 from dfdatetime import interface | 9 from dfdatetime import interface |
10 | 10 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 """Retrieves the normalized timestamp. | 64 """Retrieves the normalized timestamp. |
65 | 65 |
66 Returns: | 66 Returns: |
67 decimal.Decimal: normalized timestamp, which contains the number of | 67 decimal.Decimal: normalized timestamp, which contains the number of |
68 seconds since January 1, 1970 00:00:00 and a fraction of second used | 68 seconds since January 1, 1970 00:00:00 and a fraction of second used |
69 for increased precision, or None if the normalized timestamp cannot be | 69 for increased precision, or None if the normalized timestamp cannot be |
70 determined. | 70 determined. |
71 """ | 71 """ |
72 if self._normalized_timestamp is None: | 72 if self._normalized_timestamp is None: |
73 if self._number_of_seconds is not None and self._number_of_seconds >= 0: | 73 if self._number_of_seconds is not None and self._number_of_seconds >= 0: |
74 self._normalized_timestamp = ( | 74 self._SetNormalizedTimestamp(decimal.Decimal(self._number_of_seconds) + |
75 decimal.Decimal(self._number_of_seconds) + | 75 self._FAT_DATE_TO_POSIX_BASE) |
76 self._FAT_DATE_TO_POSIX_BASE) | |
77 | 76 |
78 return self._normalized_timestamp | 77 return self._normalized_timestamp |
79 | 78 |
80 def _GetNumberOfSeconds(self, fat_date_time): | 79 def _GetNumberOfSeconds(self, fat_date_time): |
81 """Retrieves the number of seconds from a FAT date time. | 80 """Retrieves the number of seconds from a FAT date time. |
82 | 81 |
83 Args: | 82 Args: |
84 fat_date_time (int): FAT date time. | 83 fat_date_time (int): FAT date time. |
85 | 84 |
86 Returns: | 85 Returns: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 """ | 183 """ |
185 if self._number_of_seconds is None: | 184 if self._number_of_seconds is None: |
186 return None, None, None | 185 return None, None, None |
187 | 186 |
188 try: | 187 try: |
189 number_of_days, _, _, _ = self._GetTimeValues(self._number_of_seconds) | 188 number_of_days, _, _, _ = self._GetTimeValues(self._number_of_seconds) |
190 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH) | 189 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH) |
191 | 190 |
192 except ValueError: | 191 except ValueError: |
193 return None, None, None | 192 return None, None, None |
LEFT | RIGHT |