Every line of 'python compare datetimes' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
734 def cmp_datetimes(first, second): 735 """Compare two datetime strings and sort by most recent. 736 737 :param first: A string containing a datetime 738 :param second: A string containing a datetime 739 :returns: -1 if ``first`` is more recent, 1 if ``second`` is more recent, or 0 740 if they are equivalent. 741 """ 742 parsed_first = _safe_parse_datetime(first) 743 parsed_second = _safe_parse_datetime(second) 744 if parsed_first > parsed_second: 745 return -1 746 elif parsed_first == parsed_second: 747 return 0 748 else: 749 return 1
15 def test_http_date_python(self): 16 format_date_time(time())
47 def gt(dt_str): 48 dt, _, us = dt_str.partition(".") 49 dt = datetime.strptime(dt, "%Y-%m-%dT%H:%M:%S") 50 us = int(us.rstrip("Z"), 10) 51 return dt + timedelta(microseconds=us)
41 def iso_sort(tup): 42 dummy, data = tup 43 return iso2date(data['duration']['start'])
195 def _get_date_for_comparison(self): 196 ''' 197 Function for avoiding duplication of code lines 198 ''' 199 return transform_in_date(self.year, self.month, self.day)