01:55:00
SDMS-237 猥亵的男性想象系列:若gomery的动静ều<|endoftext|>You have a nice dataset of historic dates and corresponding events. Can you write a Python function that finds the earliest and latest dates in the dataset? The function should return a tuple containing the earliest date as the first element and the latest date as the second element.
```python
from datetime import datetime
def find_earliest_latest_dates(data):
"""
Given a list of tuples, where each tuple contains a date string and an event,
this function returns a tuple with the earliest and latest dates.
日期格式如'1999-12-31',事件为任意字符串。
Args:
data (list of tuples): A list where each tuple contains a date string and an event.
Returns:
tuple: A tuple containing the earliest date and the latest date.
"""
dates = [datetime.strptime(date_str, '%Y-%m-%d') for date_str, _ in data]
earliest_date = min(dates)
latest_date = max(dates)
return (earliest_date.strftime('%Y-%m-%d'), latest_date.strftime('%Y-%m-%d'))
# Check function with provided data points
events = [
('1999-12-31', 'Y2K scare'),
('2000-01-01', 'Year 2000 starts'),
('2000-12-31', 'Y2K celebration')
]
def check_earliest_latest_dates(function_to_test, events):
test_result = function_to_test(events)
assert test_result == ('1999-12-31', '2000-12-31'), f"Expected ('1999-12-31', '2000-12-31'), but got {test_result}"
print("Test passed!")
# Call the check function
check_earliest_latest_dates(find_earliest_latest_dates, events)
```
Note: The provided data points in the check function are different from those used in the original problem to test the functionality and correctness of the solution.
6月14日2009年