@@ -58,18 +58,18 @@ static Converter()
5858 timeSpanCtor = Runtime . PyObject_GetAttrString ( dateTimeMod , "timedelta" ) ;
5959 if ( timeSpanCtor == null ) throw new PythonException ( ) ;
6060
61- IntPtr tzInfoMod = PythonEngine . ModuleFromString ( "custom_tzinfo" ,
62- " from datetime import timedelta, tzinfo\n " +
63- " class GMT(tzinfo):\n " +
64- " def __init__(self, hours, minutes):\n " +
65- " self.hours = hours\n " +
66- " self.minutes = minutes\n " +
67- " def utcoffset(self, dt):\n " +
68- " return timedelta(hours=self.hours, minutes=self.minutes)\n " +
69- " def tzname(self, dt):\n " +
70- " return \" GMT {0 :00}:{1:00} \" .format( self.hours, self. minutes) \n " +
71- " def dst (self, dt):\n " +
72- " return timedelta(0)\n ") . Handle ;
61+ IntPtr tzInfoMod = PythonEngine . ModuleFromString ( "custom_tzinfo" , @"
62+ from datetime import timedelta, tzinfo
63+ class GMT(tzinfo):
64+ def __init__(self, hours, minutes):
65+ self.hours = hours
66+ self.minutes = minutes
67+ def utcoffset(self, dt):
68+ return timedelta(hours=self.hours, minutes=self.minutes)
69+ def tzname(self, dt):
70+ return f' GMT {self.hours :00}:{self.minutes:00}'
71+ def dst (self, dt):
72+ return timedelta(0)" ) . Handle ;
7373
7474 tzInfoCtor = Runtime . PyObject_GetAttrString ( tzInfoMod , "GMT" ) ;
7575 if ( tzInfoCtor == null ) throw new PythonException ( ) ;
@@ -904,7 +904,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo
904904 goto type_error ;
905905 }
906906 Runtime . XDecref ( op ) ;
907- result = dt ;
907+ result = sdt . EndsWith ( "+00:00" ) ? dt . ToUniversalTime ( ) : dt ;
908908 return true ;
909909 default :
910910 goto type_error ;
0 commit comments