MCPcopy Create free account
hub / github.com/geekcomputers/Python / parse_timestamp

Function parse_timestamp

time_delta.py:38–50  ·  view source on GitHub ↗

Parse a timestamp string into a datetime object. Args: timestamp: String in the format "Day dd Mon yyyy hh:mm:ss +xxxx" Returns: A datetime object with timezone information

(timestamp: str)

Source from the content-addressed store, hash-verified

36
37
38def parse_timestamp(timestamp: str) -> datetime.datetime:
39 """
40 Parse a timestamp string into a datetime object.
41
42 Args:
43 timestamp: String in the format "Day dd Mon yyyy hh:mm:ss +xxxx"
44
45 Returns:
46 A datetime object with timezone information
47 """
48 # Define the format string to match the input timestamp format
49 format_str = "%a %d %b %Y %H:%M:%S %z"
50 return datetime.datetime.strptime(timestamp, format_str)
51
52
53def calculate_time_delta(t1: str, t2: str) -> int:

Callers 1

calculate_time_deltaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected