Ejemplo n.º 1
0
 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')
Ejemplo n.º 2
0
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"
Ejemplo n.º 3
0
    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')
Ejemplo n.º 4
0
    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')
Ejemplo n.º 5
0
    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')
Ejemplo n.º 6
0
    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')
Ejemplo n.º 7
0
    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')
Ejemplo n.º 8
0
    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')
Ejemplo n.º 9
0
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"
Ejemplo n.º 10
0
    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)
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
    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 ''
Ejemplo n.º 13
0
    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 ""
Ejemplo n.º 14
0
 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')
Ejemplo n.º 15
0
 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')
Ejemplo n.º 16
0
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"
Ejemplo n.º 17
0
 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')