A library that computes the ephemerides.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314
  1. #!/usr/bin/env python3
  2. from datetime import datetime, timezone, timedelta
  3. def translate_to_timezone(date: datetime, to_tz: int, from_tz: int = None):
  4. if from_tz is not None:
  5. source_tz = timezone(timedelta(hours=from_tz))
  6. else:
  7. source_tz = timezone.utc
  8. return date.replace(tzinfo=source_tz).astimezone(
  9. tz=timezone(timedelta(hours=to_tz))
  10. )