| 145 | self.am_pm = am_pm |
| 146 | |
| 147 | def __calc_alt_digits(self): |
| 148 | # Set self.LC_alt_digits by using time.strftime(). |
| 149 | |
| 150 | # The magic data should contain all decimal digits. |
| 151 | time_tuple = time.struct_time((1998, 1, 27, 10, 43, 56, 1, 27, 0)) |
| 152 | s = time.strftime("%x%X", time_tuple) |
| 153 | if s.isascii(): |
| 154 | # Fast path -- all digits are ASCII. |
| 155 | self.LC_alt_digits = () |
| 156 | return |
| 157 | |
| 158 | digits = ''.join(sorted(set(re.findall(r'\d', s)))) |
| 159 | if len(digits) == 10 and ord(digits[-1]) == ord(digits[0]) + 9: |
| 160 | # All 10 decimal digits from the same set. |
| 161 | if digits.isascii(): |
| 162 | # All digits are ASCII. |
| 163 | self.LC_alt_digits = () |
| 164 | return |
| 165 | |
| 166 | self.LC_alt_digits = [a + b for a in digits for b in digits] |
| 167 | # Test whether the numbers contain leading zero. |
| 168 | time_tuple2 = time.struct_time((2000, 1, 1, 1, 1, 1, 5, 1, 0)) |
| 169 | if self.LC_alt_digits[1] not in time.strftime("%x %X", time_tuple2): |
| 170 | self.LC_alt_digits[:10] = digits |
| 171 | return |
| 172 | |
| 173 | # Either non-Gregorian calendar or non-decimal numbers. |
| 174 | if {'\u4e00', '\u4e03', '\u4e5d', '\u5341', '\u5eff'}.issubset(s): |
| 175 | # lzh_TW |
| 176 | self.LC_alt_digits = lzh_TW_alt_digits |
| 177 | return |
| 178 | |
| 179 | self.LC_alt_digits = None |
| 180 | |
| 181 | def __calc_date_time(self): |
| 182 | # Set self.LC_date_time, self.LC_date, self.LC_time and |