python-intl 0.3.1__py3-none-any.whl → 0.4.0__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.
@@ -431,3 +431,12 @@ class DateTimeFormat:
431
431
  type="literal",
432
432
  value="".join(literal_chars),
433
433
  )
434
+
435
+ @cached_property
436
+ def _icu_dateinterval_format(self) -> icu.DateIntervalFormat: # ty: ignore[unresolved-attribute]
437
+ possible_skeletons = list(_options_to_possible_skeletons(self.options))
438
+ return icu.DateIntervalFormat.createInstance(possible_skeletons[0], self._icu_locale) # ty: ignore[unresolved-attribute]
439
+
440
+ def format_range(self, start_datetime: dt.datetime, end_datetime: dt.datetime) -> str:
441
+ icu_date_interval = icu.DateInterval(start_datetime, end_datetime) # ty: ignore[unresolved-attribute]
442
+ return self._icu_dateinterval_format.format(icu_date_interval)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-intl
3
- Version: 0.3.1
3
+ Version: 0.4.0
4
4
  Summary: Python implementation of the Intl JavaScript API
5
5
  Author: David Danier
6
6
  Author-email: David Danier <david.danier@gmail.com>
@@ -21,6 +21,11 @@ the "same" code works on JavaScript and Python, with similar results.
21
21
  **Status:** This is very much work in progress. Currently only `Intl.DateTimeFormat`
22
22
  exists and this also is not complete yet.
23
23
 
24
+ **Note:** There are a lot of tests running the Python implementation against the
25
+ JavaScript one and comparing the results. In general things should be pretty
26
+ stable there. Still there are some cases with known differences. Also note
27
+ that results depend on the ICU version you have installed on your machine.
28
+
24
29
  ## General notes about the Python adaption
25
30
 
26
31
  All names will be using the Python style rules. This means instead of
@@ -55,12 +60,14 @@ Intl.DateTimeFormatOptions(time_zone_name="short_offset").to_json()
55
60
  #### Example usage
56
61
 
57
62
  ```python
58
- import datetime
63
+ import datetime as dt
59
64
  import python_intl as Intl
60
65
 
61
- datetime_ = datetime.datetime(2026, 8, 15)
66
+ datetime = dt.datetime(2026, 8, 15)
62
67
  formatter = Intl.DateTimeFormat("de-DE", {"year": "numeric", "month": "2-digit", "day": "2-digit"})
63
- formatter.format(datetime_) # Will output the German format: "15.08.2026"
68
+ formatter.format(datetime) # Will output the German format: "15.08.2026"
69
+ datetime_till = dt.datetime(2026, 9, 7)
70
+ formatter.format_range(datetime, datetime_till) # Will output the German format: "15.08. – 07.09.2026"
64
71
  ```
65
72
 
66
73
  #### Compatibility
@@ -70,7 +77,7 @@ formatter.format(datetime_) # Will output the German format: "15.08.2026"
70
77
  | `DateTimeFormat.format` | ✅ | |
71
78
  | `DateTimeFormat.formatToParts` | ✅ | `DateTimeFormat.format_to_parts` |
72
79
  | `DateTimeFormat.supportedLocalesOf` | ❌ | |
73
- | `DateTimeFormat.formatRange` | ❌ | |
80
+ | `DateTimeFormat.formatRange` | ✅ | `DateTimeFormat.format_range` |
74
81
  | `DateTimeFormat.formatRangeToParts` | ❌ | |
75
82
  | `DateTimeFormat.resolvedOptions` | ❌ | |
76
83
 
@@ -0,0 +1,6 @@
1
+ python_intl/__init__.py,sha256=FDYPQdhs0eFAyCLzRB6lcvFHvnXHkYyNI9GQIomQxrw,240
2
+ python_intl/datetimeformat.py,sha256=JWl9FxaaH8AT7vPwrXZoJSVyE8vD6hFOEqt2iyp3xAY,14805
3
+ python_intl-0.4.0.dist-info/licenses/LICENSE,sha256=vBhn8BZCY-G3D6-ca99f4FU3ggdJSrKBTa3Yk8ZIAN8,1078
4
+ python_intl-0.4.0.dist-info/WHEEL,sha256=4OL6Foqnnp3xRY5wMkjgc25_i5YJC6dKsC6LPcjqEoU,80
5
+ python_intl-0.4.0.dist-info/METADATA,sha256=KMEm3bS4jPYMjlCCnB8tC1c0OG-buPXTiHI3sXWGuRE,3977
6
+ python_intl-0.4.0.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- python_intl/__init__.py,sha256=FDYPQdhs0eFAyCLzRB6lcvFHvnXHkYyNI9GQIomQxrw,240
2
- python_intl/datetimeformat.py,sha256=LfYHAR0QL0FYuRlMeQScf5hEEkU8j7M8SWLRyPXtfTg,14197
3
- python_intl-0.3.1.dist-info/licenses/LICENSE,sha256=vBhn8BZCY-G3D6-ca99f4FU3ggdJSrKBTa3Yk8ZIAN8,1078
4
- python_intl-0.3.1.dist-info/WHEEL,sha256=4OL6Foqnnp3xRY5wMkjgc25_i5YJC6dKsC6LPcjqEoU,80
5
- python_intl-0.3.1.dist-info/METADATA,sha256=crNk1srisN3yyfAkzPdQSoVkQGxnF6bAdSR_jG87LWM,3520
6
- python_intl-0.3.1.dist-info/RECORD,,