jalalix 0.1.0__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.
@@ -0,0 +1,45 @@
1
+ # Byte-compiled / cache
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+
7
+ # Distribution / packaging
8
+ build/
9
+ dist/
10
+ *.egg-info/
11
+ .eggs/
12
+ *.egg
13
+ pip-wheel-metadata/
14
+
15
+ # Virtual environments
16
+ .venv/
17
+ venv/
18
+ ENV/
19
+ env/
20
+
21
+ # Test / coverage
22
+ .pytest_cache/
23
+ .coverage
24
+ .coverage.*
25
+ htmlcov/
26
+ .tox/
27
+ .nox/
28
+ coverage.xml
29
+ *.cover
30
+
31
+ # Type checkers / linters
32
+ .mypy_cache/
33
+ .ruff_cache/
34
+ .pytype/
35
+ .pyre/
36
+
37
+ # IDE / OS
38
+ .idea/
39
+ .vscode/
40
+ *.swp
41
+ .DS_Store
42
+
43
+ # Local env
44
+ .env
45
+ .env.*
@@ -0,0 +1,5 @@
1
+ # Release Notes
2
+ All notable changes to this package will be documented in this file.
3
+
4
+ ## 0.1.0
5
+ - Initial commit
jalalix-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Hossein Maklavani
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
jalalix-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.5
2
+ Name: jalalix
3
+ Version: 0.1.0
4
+ Summary: Jalali (Persian/Shamsi) calendar for Python. Pure Python, no runtime dependencies.
5
+ Project-URL: Homepage, https://jalalix.com
6
+ Project-URL: Documentation, https://jalalix.com
7
+ Project-URL: Repository, https://github.com/jalalix/python
8
+ Project-URL: Issues, https://github.com/jalalix/python/issues
9
+ Author-email: Hossein Maklavani <hos.mohamadi@gmail.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: calendar,date,farsi,jalaali,jalali,jalalix,khorshidi,persian,python,shamsi
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.9
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # JalaliX
29
+
30
+ Jalali (Persian / Shamsi) calendar for Python. Pure Python 3.9+, no runtime dependencies.
31
+
32
+ [![PyPI](https://img.shields.io/pypi/v/jalalix.svg)](https://pypi.org/project/jalalix/)
33
+ [![license](https://img.shields.io/pypi/l/jalalix.svg)](./LICENSE)
34
+
35
+ ```bash
36
+ pip install jalalix
37
+ ```
38
+
39
+ ```python
40
+ from jalalix import JalaliX
41
+
42
+ date = JalaliX.create('2025-02-25')
43
+
44
+ date.format('YYYY/MM/DD') # 1403/12/07
45
+ date.format('DD MMM YYYY', {'persianDigits': True}) # ۰۷ اسفند ۱۴۰۳
46
+
47
+ JalaliX.parseJalali('1403/12/07').toISODate() # 2025-02-25
48
+ ```
49
+
50
+ `toISODate()` uses local calendar getters. Prefer it when you need a calendar date string without UTC shift surprises.
51
+
52
+ ## Install
53
+
54
+ ```bash
55
+ pip install jalalix
56
+ ```
57
+
58
+ ```python
59
+ from jalalix import JalaliX
60
+ ```
61
+
62
+ ## Usage
63
+
64
+ ### create / format
65
+
66
+ ```python
67
+ now = JalaliX.create(datetime.now(), {'timezone': 'Asia/Tehran'})
68
+
69
+ now.format('YYYY/MM/DD')
70
+ now.format('WN، DD MMM YYYY')
71
+ now.format('YYYY/MM/DD', {'persianDigits': True})
72
+ now.format('DD MMM YYYY', {'calendar': 'gregorian'})
73
+ ```
74
+
75
+ `format` also accepts the older positional form: `format(str, persianDigits?, gregorian?)`.
76
+
77
+ ### parseJalali
78
+
79
+ ```python
80
+ JalaliX.parseJalali('1403/12/07')
81
+ JalaliX.parseJalali('۱۴۰۳-۱۲-۰۷ 14:30')
82
+ ```
83
+
84
+ ### toISODate
85
+
86
+ ```python
87
+ d = JalaliX.create('2025-02-25')
88
+
89
+ d.toISODate() # 2025-02-25 (local Gregorian getters)
90
+ d.toISODate('jalali') # 1403-12-07
91
+ ```
92
+
93
+ ### add / start / end
94
+
95
+ ```python
96
+ JalaliX.create('2025-02-25').addMonths(1).getStartOfMonth().format('YYYY/MM/DD')
97
+ ```
98
+
99
+ ### Persian digits
100
+
101
+ ```python
102
+ JalaliX.toPersian('1403/12/07') # ۱۴۰۳/۱۲/۰۷
103
+ JalaliX.fromPersian('۱۴۰۳/۱۲/۰۷') # 1403/12/07
104
+ ```
105
+
106
+ ## Months
107
+
108
+ This is easy to get wrong:
109
+
110
+ - `getMonth()` -> 1..12 (Farvardin = 1)
111
+ - `setMonth(m)` / `setFullYear(y, m)` -> 0..11, same as JS `Date` (Farvardin = 0)
112
+
113
+ ```python
114
+ d = JalaliX.create(datetime.now())
115
+ d.setFullYear(1404, 0, 1) # 1 Farvardin 1404
116
+ d.getMonth() # 1
117
+ ```
118
+
119
+ ## Timezone
120
+
121
+ Internal storage is a **UTC Unix millisecond instant** plus an IANA timezone id. `setTimezone` is **instant-preserving**: the timestamp stays the same; wall clock / Jalali day may change.
122
+
123
+ ```python
124
+ d = JalaliX.create(1740430800000)
125
+ tehran = d.setTimezone("Asia/Tehran")
126
+ tehran.format("YYYY/MM/DD") # 1403/12/07
127
+ tehran.format("HH:mm:ss") # 00:30:00
128
+
129
+ utc = d.setTimezone("UTC")
130
+ utc.format("YYYY/MM/DD") # 1403/12/06
131
+ utc.format("HH:mm:ss") # 21:00:00
132
+ ```
133
+
134
+ - **Aliases:** `utc` / `gmt` -> `UTC`; `local` / `default` / `system` -> host IANA zone when detectable, else `UTC`.
135
+ - **Invalid zone** -> `ValueError`.
136
+ - Offsets use stdlib `zoneinfo`, with a **vendored** TZif set under `jalalix/zoneinfo/` (`UTC`, `Etc/UTC`, `Asia/Tehran`, `Asia/Tokyo`, `Europe/London`, `America/New_York`) so Windows works without the PyPI `tzdata` package.
137
+
138
+ ## Format tokens
139
+
140
+ | Token | |
141
+ | ------------------- | ------------------------------- |
142
+ | `YYYY` `YY` | year |
143
+ | `MMM` `MM` `M` | month name / number |
144
+ | `DD` `D` | day |
145
+ | `HH` `hh` `mm` `ss` | time |
146
+ | `A` `a` | meridiem (ق.ظ. / ب.ظ. or AM/PM) |
147
+ | `WN` `WL` | weekday name / letter |
148
+ | `w` `DDD` | week of year / day of year |
149
+ | `X` `x` | unix seconds / ms |
150
+
151
+ ```python
152
+ date.format('YYYY/MM/DD')
153
+ date.format('YYYY/MM/DD', {'persianDigits': True})
154
+ date.format('DD MMM YYYY', {'calendar': 'gregorian'})
155
+ ```
156
+
157
+ ## API
158
+
159
+ Static:
160
+
161
+ - `create(date, options?)` — timestamp (ms), ISO string, `datetime`, or `date`
162
+ - `parseJalali(str, options?)`
163
+ - `isValidDate(value)`
164
+ - `toPersian(str)` / `fromPersian(str)`
165
+ - `compare(a, b)` — true if `a` is before `b`
166
+
167
+ `options` is `{'timezone': str}` (e.g. `'Asia/Tehran'`).
168
+
169
+ Instance (main ones):
170
+
171
+ - `format(...)`, `toISODate(calendar?)`
172
+ - `toString()`, `toDateString()`, `toLocaleDateString()`, `toLocaleTimeString()`
173
+ - `getFullYear()`, `getMonth()`, `getDate()`, `getDay()`, …
174
+ - `setFullYear`, `setMonth`, `setDate`, `setHours`, … (mutate and return `self`)
175
+ - `addYears`, `addMonths`, `addWeeks`, `addDays`
176
+ - `getStartOfYear` / `Month` / `Week` / `Day` and matching `getEndOf*`
177
+ - `clone()`, `setTimezone(tz)`, `getTimezone()`
178
+
179
+ Method names match the TypeScript package (camelCase).
180
+
181
+ ## Links
182
+
183
+ - https://pypi.org/project/jalalix/
184
+ - https://jalalix.com
185
+ - https://github.com/jalalix/python
186
+ - [CHANGELOG.md](./CHANGELOG.md)
187
+
188
+ ## License
189
+
190
+ MIT
@@ -0,0 +1,163 @@
1
+ # JalaliX
2
+
3
+ Jalali (Persian / Shamsi) calendar for Python. Pure Python 3.9+, no runtime dependencies.
4
+
5
+ [![PyPI](https://img.shields.io/pypi/v/jalalix.svg)](https://pypi.org/project/jalalix/)
6
+ [![license](https://img.shields.io/pypi/l/jalalix.svg)](./LICENSE)
7
+
8
+ ```bash
9
+ pip install jalalix
10
+ ```
11
+
12
+ ```python
13
+ from jalalix import JalaliX
14
+
15
+ date = JalaliX.create('2025-02-25')
16
+
17
+ date.format('YYYY/MM/DD') # 1403/12/07
18
+ date.format('DD MMM YYYY', {'persianDigits': True}) # ۰۷ اسفند ۱۴۰۳
19
+
20
+ JalaliX.parseJalali('1403/12/07').toISODate() # 2025-02-25
21
+ ```
22
+
23
+ `toISODate()` uses local calendar getters. Prefer it when you need a calendar date string without UTC shift surprises.
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ pip install jalalix
29
+ ```
30
+
31
+ ```python
32
+ from jalalix import JalaliX
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ### create / format
38
+
39
+ ```python
40
+ now = JalaliX.create(datetime.now(), {'timezone': 'Asia/Tehran'})
41
+
42
+ now.format('YYYY/MM/DD')
43
+ now.format('WN، DD MMM YYYY')
44
+ now.format('YYYY/MM/DD', {'persianDigits': True})
45
+ now.format('DD MMM YYYY', {'calendar': 'gregorian'})
46
+ ```
47
+
48
+ `format` also accepts the older positional form: `format(str, persianDigits?, gregorian?)`.
49
+
50
+ ### parseJalali
51
+
52
+ ```python
53
+ JalaliX.parseJalali('1403/12/07')
54
+ JalaliX.parseJalali('۱۴۰۳-۱۲-۰۷ 14:30')
55
+ ```
56
+
57
+ ### toISODate
58
+
59
+ ```python
60
+ d = JalaliX.create('2025-02-25')
61
+
62
+ d.toISODate() # 2025-02-25 (local Gregorian getters)
63
+ d.toISODate('jalali') # 1403-12-07
64
+ ```
65
+
66
+ ### add / start / end
67
+
68
+ ```python
69
+ JalaliX.create('2025-02-25').addMonths(1).getStartOfMonth().format('YYYY/MM/DD')
70
+ ```
71
+
72
+ ### Persian digits
73
+
74
+ ```python
75
+ JalaliX.toPersian('1403/12/07') # ۱۴۰۳/۱۲/۰۷
76
+ JalaliX.fromPersian('۱۴۰۳/۱۲/۰۷') # 1403/12/07
77
+ ```
78
+
79
+ ## Months
80
+
81
+ This is easy to get wrong:
82
+
83
+ - `getMonth()` -> 1..12 (Farvardin = 1)
84
+ - `setMonth(m)` / `setFullYear(y, m)` -> 0..11, same as JS `Date` (Farvardin = 0)
85
+
86
+ ```python
87
+ d = JalaliX.create(datetime.now())
88
+ d.setFullYear(1404, 0, 1) # 1 Farvardin 1404
89
+ d.getMonth() # 1
90
+ ```
91
+
92
+ ## Timezone
93
+
94
+ Internal storage is a **UTC Unix millisecond instant** plus an IANA timezone id. `setTimezone` is **instant-preserving**: the timestamp stays the same; wall clock / Jalali day may change.
95
+
96
+ ```python
97
+ d = JalaliX.create(1740430800000)
98
+ tehran = d.setTimezone("Asia/Tehran")
99
+ tehran.format("YYYY/MM/DD") # 1403/12/07
100
+ tehran.format("HH:mm:ss") # 00:30:00
101
+
102
+ utc = d.setTimezone("UTC")
103
+ utc.format("YYYY/MM/DD") # 1403/12/06
104
+ utc.format("HH:mm:ss") # 21:00:00
105
+ ```
106
+
107
+ - **Aliases:** `utc` / `gmt` -> `UTC`; `local` / `default` / `system` -> host IANA zone when detectable, else `UTC`.
108
+ - **Invalid zone** -> `ValueError`.
109
+ - Offsets use stdlib `zoneinfo`, with a **vendored** TZif set under `jalalix/zoneinfo/` (`UTC`, `Etc/UTC`, `Asia/Tehran`, `Asia/Tokyo`, `Europe/London`, `America/New_York`) so Windows works without the PyPI `tzdata` package.
110
+
111
+ ## Format tokens
112
+
113
+ | Token | |
114
+ | ------------------- | ------------------------------- |
115
+ | `YYYY` `YY` | year |
116
+ | `MMM` `MM` `M` | month name / number |
117
+ | `DD` `D` | day |
118
+ | `HH` `hh` `mm` `ss` | time |
119
+ | `A` `a` | meridiem (ق.ظ. / ب.ظ. or AM/PM) |
120
+ | `WN` `WL` | weekday name / letter |
121
+ | `w` `DDD` | week of year / day of year |
122
+ | `X` `x` | unix seconds / ms |
123
+
124
+ ```python
125
+ date.format('YYYY/MM/DD')
126
+ date.format('YYYY/MM/DD', {'persianDigits': True})
127
+ date.format('DD MMM YYYY', {'calendar': 'gregorian'})
128
+ ```
129
+
130
+ ## API
131
+
132
+ Static:
133
+
134
+ - `create(date, options?)` — timestamp (ms), ISO string, `datetime`, or `date`
135
+ - `parseJalali(str, options?)`
136
+ - `isValidDate(value)`
137
+ - `toPersian(str)` / `fromPersian(str)`
138
+ - `compare(a, b)` — true if `a` is before `b`
139
+
140
+ `options` is `{'timezone': str}` (e.g. `'Asia/Tehran'`).
141
+
142
+ Instance (main ones):
143
+
144
+ - `format(...)`, `toISODate(calendar?)`
145
+ - `toString()`, `toDateString()`, `toLocaleDateString()`, `toLocaleTimeString()`
146
+ - `getFullYear()`, `getMonth()`, `getDate()`, `getDay()`, …
147
+ - `setFullYear`, `setMonth`, `setDate`, `setHours`, … (mutate and return `self`)
148
+ - `addYears`, `addMonths`, `addWeeks`, `addDays`
149
+ - `getStartOfYear` / `Month` / `Week` / `Day` and matching `getEndOf*`
150
+ - `clone()`, `setTimezone(tz)`, `getTimezone()`
151
+
152
+ Method names match the TypeScript package (camelCase).
153
+
154
+ ## Links
155
+
156
+ - https://pypi.org/project/jalalix/
157
+ - https://jalalix.com
158
+ - https://github.com/jalalix/python
159
+ - [CHANGELOG.md](./CHANGELOG.md)
160
+
161
+ ## License
162
+
163
+ MIT
@@ -0,0 +1,55 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "jalalix"
7
+ version = "0.1.0"
8
+ description = "Jalali (Persian/Shamsi) calendar for Python. Pure Python, no runtime dependencies."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ { name = "Hossein Maklavani", email = "hos.mohamadi@gmail.com" },
14
+ ]
15
+ keywords = [
16
+ "jalalix",
17
+ "jalali",
18
+ "jalaali",
19
+ "shamsi",
20
+ "persian",
21
+ "farsi",
22
+ "khorshidi",
23
+ "calendar",
24
+ "date",
25
+ "python",
26
+ ]
27
+ classifiers = [
28
+ "Development Status :: 4 - Beta",
29
+ "Intended Audience :: Developers",
30
+ "License :: OSI Approved :: MIT License",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.9",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Programming Language :: Python :: 3.13",
37
+ "Topic :: Software Development :: Libraries :: Python Modules",
38
+ ]
39
+ dependencies = []
40
+
41
+ [project.urls]
42
+ Homepage = "https://jalalix.com"
43
+ Documentation = "https://jalalix.com"
44
+ Repository = "https://github.com/jalalix/python"
45
+ Issues = "https://github.com/jalalix/python/issues"
46
+
47
+ [project.optional-dependencies]
48
+ dev = ["pytest>=7.0"]
49
+
50
+ [tool.hatch.build.targets.wheel]
51
+ packages = ["src/jalalix"]
52
+
53
+ [tool.pytest.ini_options]
54
+ testpaths = ["tests"]
55
+ pythonpath = ["src"]
@@ -0,0 +1,6 @@
1
+ """JalaliX — Jalali (Persian / Shamsi) calendar for Python."""
2
+
3
+ from .jalalix import JalaliX
4
+
5
+ __all__ = ["JalaliX"]
6
+ __version__ = "0.1.0"