opendate 0.1.5__py3-none-any.whl → 0.1.6__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 CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = '0.1.5'
1
+ __version__ = '0.1.6'
2
2
 
3
3
  import datetime as _datetime
4
4
 
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 = UTC,
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
- return cls(obj.hour, obj.minute, obj.second, obj.microsecond,
1068
- tzinfo=obj.tzinfo or tz)
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 = UTC,
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, obj.tzinfo or tz)
1290
+ obj.second, obj.microsecond, tzinfo=tz)
1288
1291
 
1289
1292
 
1290
1293
  class IntervalError(AttributeError):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opendate
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: Python business datetimes
5
5
  Home-page: https://github.com/bissli/opendate
6
6
  License: MIT
@@ -0,0 +1,7 @@
1
+ date/__init__.py,sha256=vPv4a112UZpPY0IShVpSq4ffImTTinxuySxWt1vyeS0,2747
2
+ date/date.py,sha256=S10D2_VtXraKzpdS0xtbzLEF_n8ny0Xadmtnc4AKSCk,55943
3
+ date/extras.py,sha256=7xsOsdhKrmGoyLl5W4Xhg9TfuytaaIH7uKWW9PvR5sE,2832
4
+ opendate-0.1.6.dist-info/LICENSE,sha256=V4Rx8WWy7v8Fim6PHcEBszpZkDLbCHeorz1e_gr0Cbk,1111
5
+ opendate-0.1.6.dist-info/METADATA,sha256=mbJikEalgLHajmzvTEF_MRiLUPGX0u94I5DdFnva6JQ,1841
6
+ opendate-0.1.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
+ opendate-0.1.6.dist-info/RECORD,,
@@ -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,,