コード例 #1
0
ファイル: test_helpers.py プロジェクト: gitter-badger/ckan
 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')
コード例 #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"
コード例 #3
0
ファイル: test_helpers.py プロジェクト: dadosgovbr/ckan
    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')
コード例 #4
0
ファイル: test_helpers.py プロジェクト: dadosgovbr/ckan
    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')
コード例 #5
0
ファイル: test_helpers.py プロジェクト: gitter-badger/ckan
    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')
コード例 #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')
コード例 #7
0
ファイル: test_helpers.py プロジェクト: gitter-badger/ckan
    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')
コード例 #8
0
ファイル: test_helpers.py プロジェクト: allanglen/ckan
    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')
コード例 #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"
コード例 #10
0
ファイル: test_helpers.py プロジェクト: dadosgovbr/ckan
    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)
コード例 #11
0
ファイル: test_helpers.py プロジェクト: espona/ckan-1
    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)
コード例 #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 ''
コード例 #13
0
ファイル: controllers.py プロジェクト: CarlQLange/ckanext-qa
    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 ""
コード例 #14
0
ファイル: test_helpers.py プロジェクト: dadosgovbr/ckan
 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')
コード例 #15
0
ファイル: test_helpers.py プロジェクト: allanglen/ckan
 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')
コード例 #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"
コード例 #17
0
ファイル: test_helpers.py プロジェクト: gitter-badger/ckan
 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')