(raw_ts)
| 15697 | _fill_aliases("updatedAt", ("updated_at", "lastUpdated", "last_updated", "modifiedAt", "modified_at", "lastModified", "last_modified", "lastUpdatedAt", "updateTime", "updated", "update_time")) |
| 15698 | |
| 15699 | def _parse_of_datetime(raw_ts): |
| 15700 | if not raw_ts or raw_ts is True or raw_ts is False: |
| 15701 | return None |
| 15702 | dt = None |
| 15703 | try: |
| 15704 | if isinstance(raw_ts, datetime): |
| 15705 | dt = raw_ts |
| 15706 | elif isinstance(raw_ts, (int, float)): |
| 15707 | if raw_ts <= 0: |
| 15708 | return None |
| 15709 | if raw_ts > 10**13: |
| 15710 | raw_ts = raw_ts / 1000.0 |
| 15711 | elif raw_ts > 10**10: |
| 15712 | raw_ts = raw_ts / 1000.0 |
| 15713 | dt = datetime.fromtimestamp(raw_ts, tz=timezone.utc) |
| 15714 | else: |
| 15715 | raw = str(raw_ts).strip() |
| 15716 | raw_norm = raw.replace("Z", "+00:00").replace("z", "+00:00") |
| 15717 | if re.fullmatch(r"\d{10,17}", raw_norm): |
| 15718 | n = float(raw_norm) |
| 15719 | if len(raw_norm) >= 13: |
| 15720 | n = n / 1000.0 |
| 15721 | dt = datetime.fromtimestamp(n, tz=timezone.utc) |
| 15722 | else: |
| 15723 | dt = datetime.fromisoformat(raw_norm) |
| 15724 | except Exception: |
| 15725 | return None |
| 15726 | |
| 15727 | if dt is None: |
| 15728 | return None |
| 15729 | if dt.tzinfo is None: |
| 15730 | dt = dt.replace(tzinfo=datetime.now().astimezone().tzinfo) |
| 15731 | dt = dt.astimezone(timezone.utc) |
| 15732 | if dt.year < 2000 or dt.year > (now_utc.year + 1): |
| 15733 | return None |
| 15734 | if abs((now_utc - dt).total_seconds()) < 120: |
| 15735 | # anti-bot/anti-clock artifacts, avoid timestamp spoofing |
| 15736 | return None |
| 15737 | return dt |
| 15738 | |
| 15739 | def _format_profile_ts(raw_ts): |
| 15740 | dt = _parse_of_datetime(raw_ts) |
nothing calls this directly
no outgoing calls
no test coverage detected