コード例 #1
0
    def test_string_format_datetime_tz(self, unmarshaller_factory):
        schema = Schema('string', schema_format='date-time')
        value = '2020-04-01T12:00:00+02:00'

        result = unmarshaller_factory(schema)(value)

        tzinfo = FixedOffset(2)
        assert result == datetime.datetime(2020, 4, 1, 12, 0, 0, tzinfo=tzinfo)
コード例 #2
0
    def test_string_format_datetime_tz(self, unmarshaller_factory):
        spec = {
            'type': 'string',
            'format': 'date-time',
        }
        schema = SpecPath.from_spec(spec)
        value = '2020-04-01T12:00:00+02:00'

        result = unmarshaller_factory(schema)(value)

        tzinfo = FixedOffset(2)
        assert result == datetime.datetime(2020, 4, 1, 12, 0, 0, tzinfo=tzinfo)
コード例 #3
0
    def test_string_format_datetime_tz(self, unmarshaller_factory):
        spec = {
            "type": "string",
            "format": "date-time",
        }
        schema = SpecPath.from_spec(spec)
        value = "2020-04-01T12:00:00+02:00"

        result = unmarshaller_factory(schema)(value)

        tzinfo = FixedOffset(2)
        assert result == datetime.datetime(2020, 4, 1, 12, 0, 0, tzinfo=tzinfo)
コード例 #4
0
ファイル: isotzinfo.py プロジェクト: Rigosebuta/biathlon
def build_tzinfo(tzname, tzsign='+', tzhour=0, tzmin=0):
    '''
    create a tzinfo instance according to given parameters.

    tzname:
      'Z'       ... return UTC
      '' | None ... return None
      other     ... return FixedOffset
    '''
    if tzname is None or tzname == '':
        return None
    if tzname == 'Z':
        return UTC
    tzsign = ((tzsign == '-') and -1) or 1
    return FixedOffset(tzsign * tzhour, tzsign * tzmin, tzname)
コード例 #5
0
def build_tzinfo(tzname, tzsign="+", tzhour=0, tzmin=0):
    """
    create a tzinfo instance according to given parameters.

    tzname:
      'Z'       ... return UTC
      '' | None ... return None
      other     ... return FixedOffset
    """
    if tzname is None or tzname == "":
        return None
    if tzname == "Z":
        return UTC
    tzsign = ((tzsign == "-") and -1) or 1
    return FixedOffset(tzsign * tzhour, tzsign * tzmin, tzname)