A library that computes the ephemerides.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dateutil.py 384 B

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. )