@@ -367,6 +367,10 @@ internal enum InputKind { Year, Month, Day, Hour, Minute, Second, Microsecond }
             return false;
         }
 
+        internal static int CastToInt(object o) {
+            return o is BigInteger ? (int)(BigInteger)o : (int)o;
+        }
+
         [PythonType]
         public class date : ICodeFormattable {
             internal DateTime _dateTime;
@@ -933,9 +937,6 @@ public datetime(DateTime dt)
                 return new time(hour, minute, second, microsecond, _tz);
             }
 
-            private int CastToInt(object o) {
-                return o is BigInteger ? (int)(BigInteger)o : (int)o;
-            }
             [Documentation("gets a new datetime object with the fields provided as keyword arguments replaced.")]
             public override date replace(CodeContext/*!*/ context, [ParamDictionary]IDictionary<object, object> dict) {
                 int lyear = year;
@@ -1316,16 +1317,16 @@ public class time : ICodeFormattable {
 
                     switch (key) {
                         case "hour":
-                            lhour = (int)kvp.Value;
+                            lhour = CastToInt(kvp.Value);
                             break;
                         case "minute":
-                            lminute = (int)kvp.Value;
+                            lminute = CastToInt(kvp.Value);
                             break;
                         case "second":
-                            lsecond = (int)kvp.Value;
+                            lsecond = CastToInt(kvp.Value);
                             break;
                         case "microsecond":
-                            lmicrosecond = (int)kvp.Value;
+                            lmicrosecond = CastToInt(kvp.Value);
                             break;
                         case "tzinfo":
                             tz = kvp.Value as tzinfo;