opendate 0.1.5__tar.gz → 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of opendate might be problematic. Click here for more details.
- {opendate-0.1.5 → opendate-0.1.6}/PKG-INFO +1 -1
- {opendate-0.1.5 → opendate-0.1.6}/pyproject.toml +1 -1
- {opendate-0.1.5 → opendate-0.1.6}/src/date/__init__.py +1 -1
- {opendate-0.1.5 → opendate-0.1.6}/src/date/date.py +17 -14
- {opendate-0.1.5 → opendate-0.1.6}/LICENSE +0 -0
- {opendate-0.1.5 → opendate-0.1.6}/README.md +0 -0
- {opendate-0.1.5 → opendate-0.1.6}/src/date/extras.py +0 -0
|
@@ -1040,7 +1040,7 @@ class Time(_pendulum.Time):
|
|
|
1040
1040
|
| np.datetime64
|
|
1041
1041
|
| Self
|
|
1042
1042
|
| None,
|
|
1043
|
-
tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo | None =
|
|
1043
|
+
tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo | None = None,
|
|
1044
1044
|
raise_err: bool = False,
|
|
1045
1045
|
) -> Self | None:
|
|
1046
1046
|
"""From datetime-like object
|
|
@@ -1061,11 +1061,12 @@ class Time(_pendulum.Time):
|
|
|
1061
1061
|
raise ValueError('Empty value')
|
|
1062
1062
|
return
|
|
1063
1063
|
|
|
1064
|
-
if obj.__class__ == cls:
|
|
1064
|
+
if obj.__class__ == cls and not tz:
|
|
1065
1065
|
return obj
|
|
1066
1066
|
|
|
1067
|
-
|
|
1068
|
-
|
|
1067
|
+
tz = tz or obj.tzinfo or UTC
|
|
1068
|
+
|
|
1069
|
+
return cls(obj.hour, obj.minute, obj.second, obj.microsecond, tzinfo=tz)
|
|
1069
1070
|
|
|
1070
1071
|
|
|
1071
1072
|
class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
@@ -1219,7 +1220,7 @@ class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
|
1219
1220
|
| np.datetime64
|
|
1220
1221
|
| Self
|
|
1221
1222
|
| None,
|
|
1222
|
-
tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo | None =
|
|
1223
|
+
tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo | None = None,
|
|
1223
1224
|
raise_err: bool = False,
|
|
1224
1225
|
) -> Self | None:
|
|
1225
1226
|
"""From datetime-like object
|
|
@@ -1263,28 +1264,30 @@ class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
|
1263
1264
|
raise ValueError('Empty value')
|
|
1264
1265
|
return
|
|
1265
1266
|
|
|
1266
|
-
if obj.__class__ == cls:
|
|
1267
|
+
if obj.__class__ == cls and not tz:
|
|
1267
1268
|
return obj
|
|
1268
1269
|
|
|
1269
1270
|
if isinstance(obj, pd.Timestamp):
|
|
1270
1271
|
obj = obj.to_pydatetime()
|
|
1271
|
-
return cls.instance(obj, tz=tz)
|
|
1272
|
+
return cls.instance(obj, tz=tz or UTC)
|
|
1272
1273
|
if isinstance(obj, np.datetime64):
|
|
1273
1274
|
obj = np.datetime64(obj, 'us').astype(_datetime.datetime)
|
|
1274
|
-
return cls.instance(obj, tz=tz)
|
|
1275
|
+
return cls.instance(obj, tz=tz or UTC)
|
|
1276
|
+
|
|
1277
|
+
if obj.__class__ == Date:
|
|
1278
|
+
return cls(obj.year, obj.month, obj.day, tzinfo=tz or UTC)
|
|
1279
|
+
if isinstance(obj, _datetime.date) and not isinstance(obj, _datetime.datetime):
|
|
1280
|
+
return cls(obj.year, obj.month, obj.day, tzinfo=tz or UTC)
|
|
1281
|
+
|
|
1282
|
+
tz = tz or obj.tzinfo or UTC
|
|
1275
1283
|
|
|
1276
1284
|
if obj.__class__ == Time:
|
|
1277
1285
|
return cls.combine(Date.today(), obj, tzinfo=tz)
|
|
1278
1286
|
if isinstance(obj, _datetime.time):
|
|
1279
1287
|
return cls.combine(Date.today(), obj, tzinfo=tz)
|
|
1280
1288
|
|
|
1281
|
-
if obj.__class__ == Date:
|
|
1282
|
-
return cls(obj.year, obj.month, obj.day, tzinfo=tz)
|
|
1283
|
-
if isinstance(obj, _datetime.date) and not isinstance(obj, _datetime.datetime):
|
|
1284
|
-
return cls(obj.year, obj.month, obj.day, tzinfo=tz)
|
|
1285
|
-
|
|
1286
1289
|
return cls(obj.year, obj.month, obj.day, obj.hour, obj.minute,
|
|
1287
|
-
obj.second, obj.microsecond,
|
|
1290
|
+
obj.second, obj.microsecond, tzinfo=tz)
|
|
1288
1291
|
|
|
1289
1292
|
|
|
1290
1293
|
class IntervalError(AttributeError):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|