def test_parse_rfc_2822_ignoring_offset(self): """ Parse "Tue, 15 Nov 1994 12:45:26 +0700" successfully. """ dt = h.parse_rfc_2822_date('Tue, 15 Nov 1994 12:45:26 +0700', tz_aware=False) assert_equal(dt.isoformat(), '1994-11-15T12:45:26')
def test_parse_rfc_2822_no_timezone_specified(): """ Parse "Tue, 15 Nov 1994 12:45:26" successfully. Assuming it's UTC. """ dt = h.parse_rfc_2822_date("Tue, 15 Nov 1994 12:45:26") assert dt.isoformat() == "1994-11-15T12:45:26+00:00"
def test_parse_rfc_2822_no_timezone_specified(self): """ Parse "Tue, 15 Nov 1994 12:45:26" successfully. Assuming it's UTC. """ dt = h.parse_rfc_2822_date('Tue, 15 Nov 1994 12:45:26') assert_equal(dt.isoformat(), '1994-11-15T12:45:26+00:00')
def test_parse_rfc_2822_gmt_case(self): """ Parse "Tue, 15 Nov 1994 12:45:26 GMT" successfully. GMT obs-zone specified """ dt = h.parse_rfc_2822_date('Tue, 15 Nov 1994 12:45:26 GMT') assert_equal(dt.isoformat(), '1994-11-15T12:45:26+00:00')
def test_parse_rfc_2822_gmt_case(self): """ Parse "Tue, 15 Nov 1994 12:45:26 GMT" successfully. GMT obs-zone specified """ dt = h.parse_rfc_2822_date('Tue, 15 Nov 1994 12:45:26 GMT') assert_equal(dt.isoformat(), '1994-11-15T12:45:26')
def test_parse_rfc_2822_simple_case(self): """ Parse "Tue, 15 Nov 1994 12:45:26" successfully. No zone info. """ dt = h.parse_rfc_2822_date('Tue, 15 Nov 1994 12:45:26') assert_equal(dt.isoformat(), '1994-11-15T12:45:26')
def test_parse_rfc_2822_gmt_case(): """ Parse "Tue, 15 Nov 1994 12:45:26 GMT" successfully. GMT obs-zone specified """ dt = h.parse_rfc_2822_date("Tue, 15 Nov 1994 12:45:26 GMT") assert dt.isoformat() == "1994-11-15T12:45:26+00:00"
def test_parse_rfc_2822_no_timezone_specified_assuming_local(self): """ Parse "Tue, 15 Nov 1994 12:45:26" successfully. Assuming it's local. """ dt = h.parse_rfc_2822_date('Tue, 15 Nov 1994 12:45:26', assume_utc=False) assert_equal(dt.isoformat(), '1994-11-15T12:45:26') assert_equal(dt.tzinfo, None)
def _parse_and_format_date(self, date_string): """ Parse date string in form specified in RFC 2822, and reformat to iso format. Returns the empty string if the date_string cannot be parsed """ dt = parse_rfc_2822_date(date_string) # Remove timezone information, adjusting as necessary. if dt and dt.tzinfo: dt = (dt - dt.utcoffset()).replace(tzinfo=None) return dt.isoformat() if dt else ''
def _parse_and_format_date(self, date_string): """ Parse date string in form specified in RFC 2822, and reformat to iso format. Returns the empty string if the date_string cannot be parsed """ dt = parse_rfc_2822_date(date_string) # Remove timezone information, adjusting as necessary. if dt and dt.tzinfo: dt = (dt - dt.utcoffset()).replace(tzinfo=None) return dt.isoformat() if dt else ""
def test_parse_rfc_2822_with_offset(self): """ Parse "Tue, 15 Nov 1994 12:45:26 +0700" successfully. """ dt = h.parse_rfc_2822_date('Tue, 15 Nov 1994 12:45:26 +0700') assert_equal(dt.isoformat(), '1994-11-15T12:45:26+07:00')
def test_parse_rfc_2822_with_offset(): """ Parse "Tue, 15 Nov 1994 12:45:26 +0700" successfully. """ dt = h.parse_rfc_2822_date("Tue, 15 Nov 1994 12:45:26 +0700") assert dt.isoformat() == "1994-11-15T12:45:26+07:00"
def test_parse_rfc_2822_with_offset(self): """ Parse "Tue, 15 Nov 1994 12:45:26 +0700" successfully. """ dt = h.parse_rfc_2822_date('Tue, 15 Nov 1994 12:45:26 +0700') assert_equal(dt.isoformat(), '1994-11-15T05:45:26')