opendate 0.1.3__py3-none-any.whl → 0.1.4__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.3'
1
+ __version__ = '0.1.4'
2
2
 
3
3
  import datetime as _datetime
4
4
 
@@ -51,11 +51,10 @@ def time(*args, **kwargs):
51
51
  return Time(*args, **kwargs)
52
52
 
53
53
 
54
- def parse():
55
- """Generic parser that guesses type"""
56
- raise NotImplementedError(
57
- 'Generic parser not implemented, use Date or DateTime parsers'
58
- )
54
+ def parse(s: str | None, fmt: str = None, entity: Entity = NYSE, raise_err: bool = False) -> DateTime | None:
55
+ """Parse using DateTime.parse
56
+ """
57
+ return DateTime.parse(s, entity=entity, raise_err=True)
59
58
 
60
59
 
61
60
  def instance(obj: _datetime.date | _datetime.datetime | _datetime.time) -> DateTime | Date | Time:
@@ -72,13 +71,13 @@ def instance(obj: _datetime.date | _datetime.datetime | _datetime.time) -> DateT
72
71
 
73
72
 
74
73
  def now(tz: str | _zoneinfo.ZoneInfo | None = None) -> DateTime:
75
- """Get current datetime
74
+ """Returns Datetime.now
76
75
  """
77
76
  return DateTime.now(tz)
78
77
 
79
78
 
80
79
  def today(tz: str | _zoneinfo.ZoneInfo = None) -> DateTime:
81
- """Get current date
80
+ """Returns DateTime.today
82
81
  """
83
82
  return DateTime.today(tz)
84
83
 
date/date.py CHANGED
@@ -47,6 +47,27 @@ __all__ = [
47
47
 
48
48
  def Timezone(name:str = 'US/Eastern') -> _zoneinfo.ZoneInfo:
49
49
  """Simple wrapper around Pendulum `Timezone`
50
+
51
+ Ex: sanity check US/Eastern == America/New_York
52
+
53
+ >>> winter1 = DateTime(2000, 1, 1, 12, tzinfo=Timezone('US/Eastern'))
54
+ >>> winter2 = DateTime(2000, 1, 1, 12, tzinfo=Timezone('America/New_York'))
55
+
56
+ >>> summer1 = DateTime(2000, 7, 1, 12, tzinfo=Timezone('US/Eastern'))
57
+ >>> summer2 = DateTime(2000, 7, 1, 12, tzinfo=Timezone('America/New_York'))
58
+
59
+ >>> winter = [winter1, winter2,
60
+ ... winter1.astimezone(Timezone('America/New_York')),
61
+ ... winter2.astimezone(Timezone('US/Eastern')),
62
+ ... ]
63
+ >>> assert all(x==winter[0] for x in winter)
64
+
65
+ >>> summer = [summer1, summer2,
66
+ ... summer1.astimezone(Timezone('America/New_York')),
67
+ ... summer2.astimezone(Timezone('US/Eastern')),
68
+ ... ]
69
+ >>> assert all(x==summer[0] for x in summer)
70
+
50
71
  """
51
72
  return _pendulum.tz.Timezone(name)
52
73
 
@@ -1115,7 +1136,11 @@ class DateTime(DateBusinessMixin, _pendulum.DateTime):
1115
1136
  return Time.instance(self)
1116
1137
 
1117
1138
  @classmethod
1118
- def parse(cls, s: str | int | None, raise_err: bool = False) -> Self | None:
1139
+ def parse(
1140
+ cls, s: str | int | None,
1141
+ entity: Entity = NYSE,
1142
+ raise_err: bool = False
1143
+ ) -> Self | None:
1119
1144
  """Thin layer on Date parser and our custom `Date.parse``
1120
1145
 
1121
1146
  >>> DateTime.parse('2022/1/1')
@@ -1173,7 +1198,7 @@ class DateTime(DateBusinessMixin, _pendulum.DateTime):
1173
1198
  if d is not None and t is not None:
1174
1199
  return DateTime.combine(d, t, LCL)
1175
1200
 
1176
- d = Date.parse(s)
1201
+ d = Date.parse(s, entity=entity)
1177
1202
  if d is not None:
1178
1203
  return cls(d.year, d.month, d.day, 0, 0, 0)
1179
1204
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opendate
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary:
5
5
  Home-page: https://github.com/bissli/opendate
6
6
  License: MIT
@@ -0,0 +1,7 @@
1
+ date/__init__.py,sha256=eB3ZluWh9M_QVfMOpmjeigLItgUl7mywdby88ffQfbE,2747
2
+ date/date.py,sha256=Z-8-5T8TfLtgiGe0ahK7QIgXjbBEDmrGRw8zEhiQD2Y,54819
3
+ date/extras.py,sha256=7xsOsdhKrmGoyLl5W4Xhg9TfuytaaIH7uKWW9PvR5sE,2832
4
+ opendate-0.1.4.dist-info/LICENSE,sha256=V4Rx8WWy7v8Fim6PHcEBszpZkDLbCHeorz1e_gr0Cbk,1111
5
+ opendate-0.1.4.dist-info/METADATA,sha256=up550EjO3j1IFI7F_iUrlugXe6rkcfpQpeRCQrEqgN8,1816
6
+ opendate-0.1.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
+ opendate-0.1.4.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- date/__init__.py,sha256=OUG51eAQp1unyaQT2pxSXrsU_VUorfofQ6xcGLmJ9OM,2693
2
- date/date.py,sha256=W6TcGhkRfaDNtY6gWeLfJy-pi80M10CTqWTpQKXhDEU,53971
3
- date/extras.py,sha256=7xsOsdhKrmGoyLl5W4Xhg9TfuytaaIH7uKWW9PvR5sE,2832
4
- opendate-0.1.3.dist-info/LICENSE,sha256=V4Rx8WWy7v8Fim6PHcEBszpZkDLbCHeorz1e_gr0Cbk,1111
5
- opendate-0.1.3.dist-info/METADATA,sha256=cySMy5_i5RWt0XTzOO3UUmz6qSrBONhSiEtES2HXwMI,1816
6
- opendate-0.1.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
7
- opendate-0.1.3.dist-info/RECORD,,