LEFT | RIGHT |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 """RFC2579 date-time implementation.""" | 2 """RFC2579 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 """Retrieves the normalized timestamp. | 130 """Retrieves the normalized timestamp. |
131 | 131 |
132 Returns: | 132 Returns: |
133 decimal.Decimal: normalized timestamp, which contains the number of | 133 decimal.Decimal: normalized timestamp, which contains the number of |
134 seconds since January 1, 1970 00:00:00 and a fraction of second used | 134 seconds since January 1, 1970 00:00:00 and a fraction of second used |
135 for increased precision, or None if the normalized timestamp cannot be | 135 for increased precision, or None if the normalized timestamp cannot be |
136 determined. | 136 determined. |
137 """ | 137 """ |
138 if self._normalized_timestamp is None: | 138 if self._normalized_timestamp is None: |
139 if self._number_of_seconds is not None: | 139 if self._number_of_seconds is not None: |
| 140 fraction = (decimal.Decimal(self.deciseconds) / |
| 141 definitions.DECISECONDS_PER_SECOND) |
140 self._SetNormalizedTimestamp( | 142 self._SetNormalizedTimestamp( |
141 decimal.Decimal(self._number_of_seconds) | 143 decimal.Decimal(self._number_of_seconds) + fraction) |
142 + (decimal.Decimal(self.deciseconds) | |
143 / definitions.DECISECONDS_PER_SECOND)) | |
144 | 144 |
145 return self._normalized_timestamp | 145 return self._normalized_timestamp |
146 | 146 |
147 def CopyFromDateTimeString(self, time_string): | 147 def CopyFromDateTimeString(self, time_string): |
148 """Copies a RFC2579 date-time from a date and time string. | 148 """Copies a RFC2579 date-time from a date and time string. |
149 | 149 |
150 Args: | 150 Args: |
151 time_string (str): date and time value formatted as: | 151 time_string (str): date and time value formatted as: |
152 YYYY-MM-DD hh:mm:ss.######[+-]##:## | 152 YYYY-MM-DD hh:mm:ss.######[+-]##:## |
153 | 153 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 """Retrieves the date represented by the date and time values. | 207 """Retrieves the date represented by the date and time values. |
208 | 208 |
209 Returns: | 209 Returns: |
210 tuple[int, int, int]: year, month, day of month or (None, None, None) | 210 tuple[int, int, int]: year, month, day of month or (None, None, None) |
211 if the date and time values do not represent a date. | 211 if the date and time values do not represent a date. |
212 """ | 212 """ |
213 if self._number_of_seconds is None: | 213 if self._number_of_seconds is None: |
214 return None, None, None | 214 return None, None, None |
215 | 215 |
216 return self.year, self.month, self.day_of_month | 216 return self.year, self.month, self.day_of_month |
LEFT | RIGHT |