LEFT | RIGHT |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """POSIX timestamp implementation.""" | 2 """POSIX timestamp 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 """Retrieves the normalized timestamp. | 160 """Retrieves the normalized timestamp. |
161 | 161 |
162 Returns: | 162 Returns: |
163 decimal.Decimal: normalized timestamp, which contains the number of | 163 decimal.Decimal: normalized timestamp, which contains the number of |
164 seconds since January 1, 1970 00:00:00 and a fraction of second used | 164 seconds since January 1, 1970 00:00:00 and a fraction of second used |
165 for increased precision, or None if the normalized timestamp cannot be | 165 for increased precision, or None if the normalized timestamp cannot be |
166 determined. | 166 determined. |
167 """ | 167 """ |
168 if self._normalized_timestamp is None: | 168 if self._normalized_timestamp is None: |
169 if self._timestamp is not None: | 169 if self._timestamp is not None: |
170 self._normalized_timestamp = (decimal.Decimal(self._timestamp) / | 170 self._SetNormalizedTimestamp(decimal.Decimal(self._timestamp) / |
171 definitions.MICROSECONDS_PER_SECOND) | 171 definitions.MICROSECONDS_PER_SECOND) |
172 | 172 |
173 return self._normalized_timestamp | 173 return self._normalized_timestamp |
174 | 174 |
175 def CopyFromDateTimeString(self, time_string): | 175 def CopyFromDateTimeString(self, time_string): |
176 """Copies a POSIX timestamp from a date and time string. | 176 """Copies a POSIX timestamp from a date and time string. |
177 | 177 |
178 Args: | 178 Args: |
179 time_string (str): date and time value formatted as: | 179 time_string (str): date and time value formatted as: |
180 YYYY-MM-DD hh:mm:ss.######[+-]##:## | 180 YYYY-MM-DD hh:mm:ss.######[+-]##:## |
181 | 181 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 if self.timestamp is None: | 232 if self.timestamp is None: |
233 return None, None, None | 233 return None, None, None |
234 | 234 |
235 try: | 235 try: |
236 timestamp, _ = divmod(self.timestamp, definitions.MICROSECONDS_PER_SECOND) | 236 timestamp, _ = divmod(self.timestamp, definitions.MICROSECONDS_PER_SECOND) |
237 number_of_days, _, _, _ = self._GetTimeValues(timestamp) | 237 number_of_days, _, _, _ = self._GetTimeValues(timestamp) |
238 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH) | 238 return self._GetDateValuesWithEpoch(number_of_days, self._EPOCH) |
239 | 239 |
240 except ValueError: | 240 except ValueError: |
241 return None, None, None | 241 return None, None, None |
LEFT | RIGHT |