opendate 0.1.5__py3-none-any.whl → 0.1.7__py3-none-any.whl
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.
- date/__init__.py +1 -1
- date/date.py +31 -14
- {opendate-0.1.5.dist-info → opendate-0.1.7.dist-info}/METADATA +1 -1
- opendate-0.1.7.dist-info/RECORD +7 -0
- opendate-0.1.5.dist-info/RECORD +0 -7
- {opendate-0.1.5.dist-info → opendate-0.1.7.dist-info}/LICENSE +0 -0
- {opendate-0.1.5.dist-info → opendate-0.1.7.dist-info}/WHEEL +0 -0
date/__init__.py
CHANGED
date/date.py
CHANGED
|
@@ -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,26 @@ 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)
|
|
1070
|
+
|
|
1071
|
+
@expect_time
|
|
1072
|
+
def astimezone(self, tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo):
|
|
1073
|
+
"""Convert timezone
|
|
1074
|
+
|
|
1075
|
+
>>> Time(12, 0).astimezone(Timezone('America/Sao_Paulo'))
|
|
1076
|
+
Time(9, 0, 0, tzinfo=Timezone('America/Sao_Paulo'))
|
|
1077
|
+
|
|
1078
|
+
>>> Time(12, 0, tzinfo=Timezone('Europe/Moscow')).astimezone(Timezone('America/Sao_Paulo'))
|
|
1079
|
+
Time(6, 0, 0, tzinfo=Timezone('America/Sao_Paulo'))
|
|
1080
|
+
|
|
1081
|
+
"""
|
|
1082
|
+
_dt = DateTime.combine(Date.today(), self, tzinfo=self.tzinfo or UTC)
|
|
1083
|
+
return _dt.astimezone(tz).time()
|
|
1069
1084
|
|
|
1070
1085
|
|
|
1071
1086
|
class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
@@ -1219,7 +1234,7 @@ class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
|
1219
1234
|
| np.datetime64
|
|
1220
1235
|
| Self
|
|
1221
1236
|
| None,
|
|
1222
|
-
tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo | None =
|
|
1237
|
+
tz: str | _zoneinfo.ZoneInfo | _datetime.tzinfo | None = None,
|
|
1223
1238
|
raise_err: bool = False,
|
|
1224
1239
|
) -> Self | None:
|
|
1225
1240
|
"""From datetime-like object
|
|
@@ -1263,28 +1278,30 @@ class DateTime(DateBusinessMixin, _pendulum.DateTime):
|
|
|
1263
1278
|
raise ValueError('Empty value')
|
|
1264
1279
|
return
|
|
1265
1280
|
|
|
1266
|
-
if obj.__class__ == cls:
|
|
1281
|
+
if obj.__class__ == cls and not tz:
|
|
1267
1282
|
return obj
|
|
1268
1283
|
|
|
1269
1284
|
if isinstance(obj, pd.Timestamp):
|
|
1270
1285
|
obj = obj.to_pydatetime()
|
|
1271
|
-
return cls.instance(obj, tz=tz)
|
|
1286
|
+
return cls.instance(obj, tz=tz or UTC)
|
|
1272
1287
|
if isinstance(obj, np.datetime64):
|
|
1273
1288
|
obj = np.datetime64(obj, 'us').astype(_datetime.datetime)
|
|
1274
|
-
return cls.instance(obj, tz=tz)
|
|
1289
|
+
return cls.instance(obj, tz=tz or UTC)
|
|
1290
|
+
|
|
1291
|
+
if obj.__class__ == Date:
|
|
1292
|
+
return cls(obj.year, obj.month, obj.day, tzinfo=tz or UTC)
|
|
1293
|
+
if isinstance(obj, _datetime.date) and not isinstance(obj, _datetime.datetime):
|
|
1294
|
+
return cls(obj.year, obj.month, obj.day, tzinfo=tz or UTC)
|
|
1295
|
+
|
|
1296
|
+
tz = tz or obj.tzinfo or UTC
|
|
1275
1297
|
|
|
1276
1298
|
if obj.__class__ == Time:
|
|
1277
1299
|
return cls.combine(Date.today(), obj, tzinfo=tz)
|
|
1278
1300
|
if isinstance(obj, _datetime.time):
|
|
1279
1301
|
return cls.combine(Date.today(), obj, tzinfo=tz)
|
|
1280
1302
|
|
|
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
1303
|
return cls(obj.year, obj.month, obj.day, obj.hour, obj.minute,
|
|
1287
|
-
obj.second, obj.microsecond,
|
|
1304
|
+
obj.second, obj.microsecond, tzinfo=tz)
|
|
1288
1305
|
|
|
1289
1306
|
|
|
1290
1307
|
class IntervalError(AttributeError):
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
date/__init__.py,sha256=Y89D6EmdQGQtJJ249F5ntB03zBzRrIvJauMtl7O1TNU,2747
|
|
2
|
+
date/date.py,sha256=PFB5JUxNSglg-9wYlb7Ls1xtrZE6KgAa6lppJPu-S4I,56484
|
|
3
|
+
date/extras.py,sha256=7xsOsdhKrmGoyLl5W4Xhg9TfuytaaIH7uKWW9PvR5sE,2832
|
|
4
|
+
opendate-0.1.7.dist-info/LICENSE,sha256=V4Rx8WWy7v8Fim6PHcEBszpZkDLbCHeorz1e_gr0Cbk,1111
|
|
5
|
+
opendate-0.1.7.dist-info/METADATA,sha256=C-bSRlSw0LmDwt-ayIwf21FTX18VxnWWCjcVYEUI5CM,1841
|
|
6
|
+
opendate-0.1.7.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
7
|
+
opendate-0.1.7.dist-info/RECORD,,
|
opendate-0.1.5.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
date/__init__.py,sha256=A3XyfTndgbAkc-rfT_InuuU9uORhPgGxUT_yEz-heOM,2747
|
|
2
|
-
date/date.py,sha256=K10ETuUqqhgFLU7backJGrItKqpZ97szDE0l6RWNKtY,55855
|
|
3
|
-
date/extras.py,sha256=7xsOsdhKrmGoyLl5W4Xhg9TfuytaaIH7uKWW9PvR5sE,2832
|
|
4
|
-
opendate-0.1.5.dist-info/LICENSE,sha256=V4Rx8WWy7v8Fim6PHcEBszpZkDLbCHeorz1e_gr0Cbk,1111
|
|
5
|
-
opendate-0.1.5.dist-info/METADATA,sha256=7PMv5fe7Hu2F3jc75ZE9nU2pXIpzU2ozOJfs0vs3DUE,1841
|
|
6
|
-
opendate-0.1.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
7
|
-
opendate-0.1.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|