infdate 0.2.1__tar.gz → 0.2.3__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.
infdate-0.2.3/PKG-INFO ADDED
@@ -0,0 +1,170 @@
1
+ Metadata-Version: 2.4
2
+ Name: infdate
3
+ Version: 0.2.3
4
+ Summary: Date object wrapper supporting infinity
5
+ Project-URL: Homepage, https://gitlab.com/blackstream-x/infdate
6
+ Project-URL: CI, https://gitlab.com/blackstream-x/infdate/-/pipelines
7
+ Project-URL: Bug Tracker, https://gitlab.com/blackstream-x/infdate/-/issues
8
+ Project-URL: Repository, https://gitlab.com/blackstream-x/infdate.git
9
+ Author-email: Rainer Schwarzbach <rainer@blackstream.de>
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+
26
+ # infdate
27
+
28
+ _Python module for date calculations implementing a concept of infinity_
29
+
30
+ ## Module description
31
+
32
+ ### Classes overview
33
+
34
+ └── GenericDate
35
+ ├── InfinityDate
36
+ └── RealDate
37
+
38
+
39
+ The base class **GenericDate** should not be instantiated
40
+ but can be used as a type annotation. In fact, it should be preferred
41
+ over the other classes for that purpose.
42
+
43
+ **InfinityDate** can represent either past or future infinity.
44
+ The module-level constants **INFINITE_PAST** and **INFINITE_FUTURE**
45
+ contain the two possible **InfinityDate** instance variations.
46
+
47
+ **RealDate** instances represent real dates like the standard library’s
48
+ **[datetime.date]** class, with mostly equal or similar semantics.
49
+ The module -level constants **REAL_MIN** and **REAL_MAX** are the eqivalents
50
+ of **datetime.date.min** and **datetime.date.max** as **RealDate** instances.
51
+
52
+ For any valid **RealDate** instance, the following is **True**:
53
+
54
+ ``` python
55
+ infdate.MIN < infdate.REAL_MIN <= real_date_instance <= infdate.REAL_MAX < infdate.MAX
56
+ ```
57
+
58
+ ### Module-level constants
59
+
60
+ * **INFINITE_PAST** = **InfinityDate(**_past_bound_=`True`**)** → infinity before any date
61
+ * **INFINITE_FUTURE** = **InfinityDate(**_past_bound_=`False`**)** → infinity after any date
62
+ * **MIN** = **INFINITE_PAST**
63
+ * **MAX** = **INFINITE_FUTURE**
64
+ * **REAL_MIN** = **RealDate(**_`1`, `1`, `1`_**)** → the same date as **datetime.date.min**
65
+ * **REAL_MAX** = **RealDate(**_`9999`, `12`, `31`_**)** → the same date as **datetime.date.max**
66
+ * **MIN_ORDINAL** = `1` → the same value as **datetime.date.min.toordinal()**
67
+ * **MAX_ORDINAL** = `3652059` → the same value as **datetime.date.max.toordinal()**
68
+ * **RESOLUTION** = `1` → represents the lowest possible date difference: _one day_
69
+
70
+
71
+ ### Module-level factory functions
72
+
73
+ The following factory methods from the **datetime.date** class
74
+ are provided as module-level functions:
75
+
76
+ * **fromtimestamp()** (also accepting **-math.inf** or **math.inf**)
77
+ * **fromordinal()** (also accepting **-math.inf** or **math.inf**)
78
+ * **fromisoformat()**
79
+ * **fromisocalendar()**
80
+ * **today()**
81
+
82
+ Two additional factory functions are provided:
83
+
84
+ * **fromdatetime()** to create a **RealDate** instance from a
85
+ **datetime.date** or **datetime.datetime** instance
86
+ (deprecated old name: _from_datetime_object()_).
87
+
88
+ * **fromnative()** to create an **InfinityDate** or **RealDate**
89
+ instance from a string, from **None**, **-math.inf** or **math.inf**
90
+ (deprecated old name: _from_native_type()_).
91
+
92
+ This can come handy when dealing with API representations of dates,
93
+ eg. in GitLab’s [Personal Access Tokens API].
94
+
95
+
96
+ ### Differences between the infdate module classes and datetime.date
97
+
98
+ Some notable difference from the **datetime.date** class, mainly due to the design decision to express date differences in pure numbers (ie. **float** because **math.inf** also is a float):
99
+
100
+ * infdate module classes have no **max**, **min** or **resolution** attributes,
101
+ but there are [module-level constants] serving the same purpose.
102
+
103
+ * The **.toordinal()** method returns **int**, **math.inf**, or **-math.inf**.
104
+
105
+ * Subtracting a date from an **InfinityDate** or **RealDate** always returns
106
+ an **int**, **math.inf**, or **-math.inf** instead of a **datetime.timedelta** instance.
107
+
108
+ * Likewise, you cannot add or subtract **datetime.timedelta** instances
109
+ from an **InfinityDate** or **RealDate**, only **float** or **int**
110
+ (support for adding and subtracting datetime.timedelta instances might be added in the future, [see the feature request]).
111
+
112
+ * infdate module classes have a **.pretty()** method that can be used to format **RealDate** instances with a format string like **.strftime()** (provided with the _fmt_ argument that defaults to the ISO format `%Y-%m-%d`),
113
+ or to apply a custom format to **InfinityDate** classes using the _inf_common_prefix_, _inf_past_suffix_ and _inf_future_suffix_ arguments.
114
+
115
+
116
+ ## Example usage
117
+
118
+ ``` pycon
119
+ >>> import infdate
120
+ >>> today = infdate.today()
121
+ >>> today
122
+ RealDate(2025, 6, 30)
123
+ >>> print(f"US date notation: {today:%m/%d/%y}")
124
+ US date notation: 06/30/25
125
+ >>> today.ctime()
126
+ 'Mon Jun 30 00:00:00 2025'
127
+ >>> today.isocalendar()
128
+ datetime.IsoCalendarDate(year=2025, week=27, weekday=1)
129
+ >>> yesterday = today - 1
130
+ >>> yesterday.ctime()
131
+ 'Sun Jun 29 00:00:00 2025'
132
+ >>> today - yesterday
133
+ 1
134
+ >>> infdate.INFINITE_PAST
135
+ InfinityDate(past_bound=True)
136
+ >>> infdate.INFINITE_FUTURE
137
+ InfinityDate(past_bound=False)
138
+ >>> infdate.INFINITE_FUTURE - today
139
+ inf
140
+ >>> infdate.INFINITE_FUTURE - infdate.INFINITE_PAST
141
+ inf
142
+ ```
143
+
144
+ **InfinityDate** and **RealDate** instances can be compared with each other, and also with **datetime.date** instances.
145
+
146
+ Subtracting **InfinityDate** or **RealDate** and **datetime.date** instances from each other also works:
147
+
148
+ ``` pycon
149
+ >>> from datetime import date
150
+ >>> stdlib_today = date.today()
151
+ >>> stdlib_today
152
+ datetime.date(2025, 6, 30)
153
+ >>> today == stdlib_today
154
+ True
155
+ >>> yesterday < stdlib_today
156
+ True
157
+ >>> yesterday - stdlib_today
158
+ -1
159
+ >>> stdlib_today - yesterday
160
+ 1
161
+ >>> stdlib_today - infdate.INFINITE_PAST
162
+ inf
163
+ ```
164
+
165
+
166
+ * * *
167
+ [datetime.date]: https://docs.python.org/3/library/datetime.html#date-objects
168
+ [Personal Access Tokens API]: https://docs.gitlab.com/api/personal_access_tokens/
169
+ [module-level constants]: #module-level-constants
170
+ [see the feature request]: https://gitlab.com/blackstream-x/infdate/-/issues/6
@@ -0,0 +1,145 @@
1
+ # infdate
2
+
3
+ _Python module for date calculations implementing a concept of infinity_
4
+
5
+ ## Module description
6
+
7
+ ### Classes overview
8
+
9
+ └── GenericDate
10
+ ├── InfinityDate
11
+ └── RealDate
12
+
13
+
14
+ The base class **GenericDate** should not be instantiated
15
+ but can be used as a type annotation. In fact, it should be preferred
16
+ over the other classes for that purpose.
17
+
18
+ **InfinityDate** can represent either past or future infinity.
19
+ The module-level constants **INFINITE_PAST** and **INFINITE_FUTURE**
20
+ contain the two possible **InfinityDate** instance variations.
21
+
22
+ **RealDate** instances represent real dates like the standard library’s
23
+ **[datetime.date]** class, with mostly equal or similar semantics.
24
+ The module -level constants **REAL_MIN** and **REAL_MAX** are the eqivalents
25
+ of **datetime.date.min** and **datetime.date.max** as **RealDate** instances.
26
+
27
+ For any valid **RealDate** instance, the following is **True**:
28
+
29
+ ``` python
30
+ infdate.MIN < infdate.REAL_MIN <= real_date_instance <= infdate.REAL_MAX < infdate.MAX
31
+ ```
32
+
33
+ ### Module-level constants
34
+
35
+ * **INFINITE_PAST** = **InfinityDate(**_past_bound_=`True`**)** → infinity before any date
36
+ * **INFINITE_FUTURE** = **InfinityDate(**_past_bound_=`False`**)** → infinity after any date
37
+ * **MIN** = **INFINITE_PAST**
38
+ * **MAX** = **INFINITE_FUTURE**
39
+ * **REAL_MIN** = **RealDate(**_`1`, `1`, `1`_**)** → the same date as **datetime.date.min**
40
+ * **REAL_MAX** = **RealDate(**_`9999`, `12`, `31`_**)** → the same date as **datetime.date.max**
41
+ * **MIN_ORDINAL** = `1` → the same value as **datetime.date.min.toordinal()**
42
+ * **MAX_ORDINAL** = `3652059` → the same value as **datetime.date.max.toordinal()**
43
+ * **RESOLUTION** = `1` → represents the lowest possible date difference: _one day_
44
+
45
+
46
+ ### Module-level factory functions
47
+
48
+ The following factory methods from the **datetime.date** class
49
+ are provided as module-level functions:
50
+
51
+ * **fromtimestamp()** (also accepting **-math.inf** or **math.inf**)
52
+ * **fromordinal()** (also accepting **-math.inf** or **math.inf**)
53
+ * **fromisoformat()**
54
+ * **fromisocalendar()**
55
+ * **today()**
56
+
57
+ Two additional factory functions are provided:
58
+
59
+ * **fromdatetime()** to create a **RealDate** instance from a
60
+ **datetime.date** or **datetime.datetime** instance
61
+ (deprecated old name: _from_datetime_object()_).
62
+
63
+ * **fromnative()** to create an **InfinityDate** or **RealDate**
64
+ instance from a string, from **None**, **-math.inf** or **math.inf**
65
+ (deprecated old name: _from_native_type()_).
66
+
67
+ This can come handy when dealing with API representations of dates,
68
+ eg. in GitLab’s [Personal Access Tokens API].
69
+
70
+
71
+ ### Differences between the infdate module classes and datetime.date
72
+
73
+ Some notable difference from the **datetime.date** class, mainly due to the design decision to express date differences in pure numbers (ie. **float** because **math.inf** also is a float):
74
+
75
+ * infdate module classes have no **max**, **min** or **resolution** attributes,
76
+ but there are [module-level constants] serving the same purpose.
77
+
78
+ * The **.toordinal()** method returns **int**, **math.inf**, or **-math.inf**.
79
+
80
+ * Subtracting a date from an **InfinityDate** or **RealDate** always returns
81
+ an **int**, **math.inf**, or **-math.inf** instead of a **datetime.timedelta** instance.
82
+
83
+ * Likewise, you cannot add or subtract **datetime.timedelta** instances
84
+ from an **InfinityDate** or **RealDate**, only **float** or **int**
85
+ (support for adding and subtracting datetime.timedelta instances might be added in the future, [see the feature request]).
86
+
87
+ * infdate module classes have a **.pretty()** method that can be used to format **RealDate** instances with a format string like **.strftime()** (provided with the _fmt_ argument that defaults to the ISO format `%Y-%m-%d`),
88
+ or to apply a custom format to **InfinityDate** classes using the _inf_common_prefix_, _inf_past_suffix_ and _inf_future_suffix_ arguments.
89
+
90
+
91
+ ## Example usage
92
+
93
+ ``` pycon
94
+ >>> import infdate
95
+ >>> today = infdate.today()
96
+ >>> today
97
+ RealDate(2025, 6, 30)
98
+ >>> print(f"US date notation: {today:%m/%d/%y}")
99
+ US date notation: 06/30/25
100
+ >>> today.ctime()
101
+ 'Mon Jun 30 00:00:00 2025'
102
+ >>> today.isocalendar()
103
+ datetime.IsoCalendarDate(year=2025, week=27, weekday=1)
104
+ >>> yesterday = today - 1
105
+ >>> yesterday.ctime()
106
+ 'Sun Jun 29 00:00:00 2025'
107
+ >>> today - yesterday
108
+ 1
109
+ >>> infdate.INFINITE_PAST
110
+ InfinityDate(past_bound=True)
111
+ >>> infdate.INFINITE_FUTURE
112
+ InfinityDate(past_bound=False)
113
+ >>> infdate.INFINITE_FUTURE - today
114
+ inf
115
+ >>> infdate.INFINITE_FUTURE - infdate.INFINITE_PAST
116
+ inf
117
+ ```
118
+
119
+ **InfinityDate** and **RealDate** instances can be compared with each other, and also with **datetime.date** instances.
120
+
121
+ Subtracting **InfinityDate** or **RealDate** and **datetime.date** instances from each other also works:
122
+
123
+ ``` pycon
124
+ >>> from datetime import date
125
+ >>> stdlib_today = date.today()
126
+ >>> stdlib_today
127
+ datetime.date(2025, 6, 30)
128
+ >>> today == stdlib_today
129
+ True
130
+ >>> yesterday < stdlib_today
131
+ True
132
+ >>> yesterday - stdlib_today
133
+ -1
134
+ >>> stdlib_today - yesterday
135
+ 1
136
+ >>> stdlib_today - infdate.INFINITE_PAST
137
+ inf
138
+ ```
139
+
140
+
141
+ * * *
142
+ [datetime.date]: https://docs.python.org/3/library/datetime.html#date-objects
143
+ [Personal Access Tokens API]: https://docs.gitlab.com/api/personal_access_tokens/
144
+ [module-level constants]: #module-level-constants
145
+ [see the feature request]: https://gitlab.com/blackstream-x/infdate/-/issues/6
@@ -1,17 +1,18 @@
1
1
  [project]
2
2
  name = "infdate"
3
- version = "0.2.1"
3
+ version = "0.2.3"
4
4
  description = "Date object wrapper supporting infinity"
5
5
  readme = "README.md"
6
6
  authors = [
7
7
  { name = "Rainer Schwarzbach", email = "rainer@blackstream.de" },
8
8
  ]
9
- requires-python = ">=3.11"
9
+ requires-python = ">=3.10"
10
10
  classifiers = [
11
11
  "Development Status :: 4 - Beta",
12
12
  "License :: OSI Approved :: MIT License",
13
13
  "Operating System :: OS Independent",
14
14
  "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
15
16
  "Programming Language :: Python :: 3.11",
16
17
  "Programming Language :: Python :: 3.12",
17
18
  "Programming Language :: Python :: 3.13",
@@ -0,0 +1,8 @@
1
+ {
2
+ "ci_pipeline_created_at": "2025-06-30T14:27:52Z",
3
+ "ci_pipeline_id": "1898131498",
4
+ "ci_pipeline_url": "https://gitlab.com/blackstream-x/infdate/-/pipelines/1898131498",
5
+ "ci_project_title": "infdate",
6
+ "ci_project_url": "https://gitlab.com/blackstream-x/infdate",
7
+ "ci_commit_sha": "0cfb32119a3d42c0e2f085596b530b6b05ddc60c"
8
+ }
@@ -4,6 +4,6 @@ _provided by [glsr-present](https://pypi.org/project/glsr-present/) 0.3.6_
4
4
 
5
5
  [infdate](https://gitlab.com/blackstream-x/infdate)
6
6
  built with pipeline
7
- [1890497916](https://gitlab.com/blackstream-x/infdate/-/pipelines/1890497916)
8
- (build started 2025-06-26T07:29:16Z)
7
+ [1898131498](https://gitlab.com/blackstream-x/infdate/-/pipelines/1898131498)
8
+ (build started 2025-06-30T14:27:52Z)
9
9
 
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="utf-8"?><testsuites name="pytest tests"><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="45" time="1.120" timestamp="2025-06-30T14:28:24.383453+00:00" hostname="runner-j1aldqxs-project-71015407-concurrent-0"><testcase classname="tests.test_dates.GenericDateBase" name="test_bool" time="0.002" /><testcase classname="tests.test_dates.GenericDateBase" name="test_eq" time="0.001" /><testcase classname="tests.test_dates.GenericDateBase" name="test_ge" time="0.055" /><testcase classname="tests.test_dates.GenericDateBase" name="test_gt" time="0.045" /><testcase classname="tests.test_dates.GenericDateBase" name="test_hash" time="0.001" /><testcase classname="tests.test_dates.GenericDateBase" name="test_isoformat" time="0.002" /><testcase classname="tests.test_dates.GenericDateBase" name="test_le" time="0.056" /><testcase classname="tests.test_dates.GenericDateBase" name="test_lt" time="0.045" /><testcase classname="tests.test_dates.GenericDateBase" name="test_nan_not_allowed" time="0.001" /><testcase classname="tests.test_dates.GenericDateBase" name="test_ne" time="0.045" /><testcase classname="tests.test_dates.GenericDateBase" name="test_pretty" time="0.001" /><testcase classname="tests.test_dates.GenericDateBase" name="test_replace" time="0.001" /><testcase classname="tests.test_dates.GenericDateBase" name="test_repr" time="0.001" /><testcase classname="tests.test_dates.GenericDateBase" name="test_str" time="0.001" /><testcase classname="tests.test_dates.GenericDateBase" name="test_strftime" time="0.001" /><testcase classname="tests.test_dates.GenericDateBase" name="test_toordinal" time="0.001" /><testcase classname="tests.test_dates.GenericDateArithmetics" name="test_add_and_radd" time="0.007" /><testcase classname="tests.test_dates.GenericDateArithmetics" name="test_add_days" time="0.005" /><testcase classname="tests.test_dates.GenericDateArithmetics" name="test_rsub_stdlib_date" time="0.001" /><testcase classname="tests.test_dates.GenericDateArithmetics" name="test_sub_date" time="0.001" /><testcase classname="tests.test_dates.GenericDateArithmetics" name="test_sub_number" time="0.004" /><testcase classname="tests.test_dates.GenericDateArithmetics" name="test_sub_stdlib_date" time="0.001" /><testcase classname="tests.test_dates.InfinityDate" name="test_pretty" time="0.001" /><testcase classname="tests.test_dates.InfinityDate" name="test_replace" time="0.001" /><testcase classname="tests.test_dates.InfinityDate" name="test_repr" time="0.001" /><testcase classname="tests.test_dates.InfinityDate" name="test_strftime" time="0.001" /><testcase classname="tests.test_dates.RealDate" name="test_attributes" time="0.001" /><testcase classname="tests.test_dates.RealDate" name="test_bool" time="0.001" /><testcase classname="tests.test_dates.RealDate" name="test_pretty" time="0.001" /><testcase classname="tests.test_dates.RealDate" name="test_proxied_methods" time="0.001" /><testcase classname="tests.test_dates.RealDate" name="test_random_date_within_limits" time="0.293" /><testcase classname="tests.test_dates.RealDate" name="test_replace" time="0.002" /><testcase classname="tests.test_dates.RealDate" name="test_repr" time="0.001" /><testcase classname="tests.test_dates.RealDate" name="test_strftime" time="0.003" /><testcase classname="tests.test_factories.FactoryFunctions" name="test_deprecated_from_datetime_object" time="0.003" /><testcase classname="tests.test_factories.FactoryFunctions" name="test_deprecated_from_native_type" time="0.005" /><testcase classname="tests.test_factories.FactoryFunctions" name="test_fromisocalendar" time="0.002" /><testcase classname="tests.test_factories.FactoryFunctions" name="test_fromisoformat" time="0.002" /><testcase classname="tests.test_factories.FactoryFunctions" name="test_fromnative" time="0.004" /><testcase classname="tests.test_factories.FactoryFunctions" name="test_fromordinal" time="0.002" /><testcase classname="tests.test_factories.FactoryFunctions" name="test_fromtimestamp" time="0.003" /><testcase classname="tests.test_factories.FactoryFunctions" name="test_fromtimestamp_errors" time="0.001" /><testcase classname="tests.test_factories.FactoryFunctions" name="test_private__from_datetime_object" time="0.002" /><testcase classname="tests.test_factories.FactoryFunctions" name="test_today" time="0.002" /><testcase classname="tests.test_factories.FactoryFunctions" name="testdatetime" time="0.002" /></testsuite></testsuites>