Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SINTEF-9012_SINDIT20 /src /sindit /util /datetime_util.py
| from datetime import datetime, timedelta | |
| from dateutil import parser | |
| def convert_string_to_local_time(timestamp: str) -> datetime: | |
| """ | |
| Convert a timestamp to the system's local timezone. | |
| """ | |
| utc_time = parser.isoparse(timestamp) | |
| local_timezone = datetime.now().astimezone().tzinfo | |
| local_time = utc_time.astimezone(local_timezone) | |
| return local_time | |
| def convert_to_local_time(timestamp: datetime) -> datetime: | |
| """ | |
| Convert a timestamp to the system's local timezone. | |
| """ | |
| local_timezone = datetime.now().astimezone().tzinfo | |
| local_time = timestamp.astimezone(local_timezone) | |
| return local_time | |
| def get_current_local_time() -> datetime: | |
| """ | |
| Get the current local time. | |
| """ | |
| local_timezone = datetime.now().astimezone().tzinfo | |
| local_time = datetime.now().astimezone(local_timezone) | |
| return local_time | |
| def add_seconds_to_timestamp(timestamp: datetime, seconds: int) -> datetime: | |
| """ | |
| Add seconds to timestamp | |
| """ | |
| return timestamp + timedelta(seconds=seconds) | |
Xet Storage Details
- Size:
- 1.05 kB
- Xet hash:
- c2125653c375ccaa0bf6da15bcf68cacd03ee82d2afe05a54dd5b33daa61adaa
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.