django-bikram 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.
- django_bikram-0.1.0/.gitignore +33 -0
- django_bikram-0.1.0/CHANGELOG.md +55 -0
- django_bikram-0.1.0/CONTRIBUTING.md +55 -0
- django_bikram-0.1.0/LICENSE +21 -0
- django_bikram-0.1.0/PKG-INFO +535 -0
- django_bikram-0.1.0/README.md +467 -0
- django_bikram-0.1.0/README.ne.md +441 -0
- django_bikram-0.1.0/django_bikram/__init__.py +62 -0
- django_bikram-0.1.0/django_bikram/calendar_data.py +414 -0
- django_bikram-0.1.0/django_bikram/convert.py +272 -0
- django_bikram-0.1.0/django_bikram/date.py +566 -0
- django_bikram-0.1.0/django_bikram/django/__init__.py +27 -0
- django_bikram-0.1.0/django_bikram/django/drf.py +191 -0
- django_bikram-0.1.0/django_bikram/django/fields.py +342 -0
- django_bikram-0.1.0/django_bikram/django/forms.py +227 -0
- django_bikram-0.1.0/django_bikram/django/lookups.py +159 -0
- django_bikram-0.1.0/django_bikram/exceptions.py +72 -0
- django_bikram-0.1.0/django_bikram/formatting.py +447 -0
- django_bikram-0.1.0/django_bikram/predict.py +351 -0
- django_bikram-0.1.0/django_bikram/py.typed +0 -0
- django_bikram-0.1.0/docs/quickstart.ne.md +200 -0
- django_bikram-0.1.0/pyproject.toml +115 -0
- django_bikram-0.1.0/tests/__init__.py +1 -0
- django_bikram-0.1.0/tests/models.py +22 -0
- django_bikram-0.1.0/tests/settings.py +21 -0
- django_bikram-0.1.0/tests/test_calendar_data.py +105 -0
- django_bikram-0.1.0/tests/test_convert.py +154 -0
- django_bikram-0.1.0/tests/test_date.py +320 -0
- django_bikram-0.1.0/tests/test_django_fields.py +302 -0
- django_bikram-0.1.0/tests/test_django_forms.py +170 -0
- django_bikram-0.1.0/tests/test_drf.py +166 -0
- django_bikram-0.1.0/tests/test_formatting.py +274 -0
- django_bikram-0.1.0/tests/test_lookups.py +144 -0
- django_bikram-0.1.0/tests/test_predict.py +214 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Byte-compiled / optimized
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
.eggs/
|
|
11
|
+
wheels/
|
|
12
|
+
|
|
13
|
+
# Test / type / lint caches
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.mypy_cache/
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
.coverage
|
|
18
|
+
.coverage.*
|
|
19
|
+
htmlcov/
|
|
20
|
+
.tox/
|
|
21
|
+
.nox/
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.venv/
|
|
25
|
+
venv/
|
|
26
|
+
env/
|
|
27
|
+
ENV/
|
|
28
|
+
|
|
29
|
+
# Editor / OS
|
|
30
|
+
.idea/
|
|
31
|
+
.vscode/
|
|
32
|
+
*.swp
|
|
33
|
+
.DS_Store
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
|
|
5
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-07-18
|
|
11
|
+
|
|
12
|
+
Initial release.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- `BSDate`: an immutable, hashable, totally ordered Bikram Sambat date with a
|
|
17
|
+
`datetime.date`-shaped API — `weekday()`, `isoformat()`, `replace()`,
|
|
18
|
+
`timedelta` arithmetic, and `BSDate - BSDate -> timedelta`.
|
|
19
|
+
- AD ↔ BS conversion (`django_bikram.convert`) via day-offset arithmetic from a
|
|
20
|
+
single anchor. `O(log years)` per conversion; never walks day by day.
|
|
21
|
+
- Verified calendar data for **1975–2083 BS** (1918-04-13 – 2027-04-13 AD),
|
|
22
|
+
cross-checked between two independent MIT-licensed sources. Dates outside the
|
|
23
|
+
range raise `DateOutOfRange` rather than being extrapolated.
|
|
24
|
+
- Two-tier calendar data: `VERIFIED_BS_MONTH_DAYS` (two-source attested) versus
|
|
25
|
+
an opt-in `PROVISIONAL_BS_MONTH_DAYS` (computed). `is_verified_year()` and
|
|
26
|
+
`BSDate.is_verified` report which tier a date belongs to.
|
|
27
|
+
- `django_bikram.predict`: a Surya-Siddhanta month-length predictor for years
|
|
28
|
+
past the verified range. `validate()` backtests it against the 109 verified
|
|
29
|
+
years (~87% of months exact, remainder ±1 day, 58/109 years fully correct);
|
|
30
|
+
`build_provisional_table()` returns the predicted table. Enable predicted
|
|
31
|
+
years with the `DJANGO_BIKRAM_PROVISIONAL_THROUGH_YEAR` environment variable
|
|
32
|
+
or `install_provisional()`; using one raises `ProvisionalDateWarning`.
|
|
33
|
+
Predictions are never presented as verified.
|
|
34
|
+
- `django_bikram.formatting`: strftime-style formatting and parsing with
|
|
35
|
+
independent language (English/Nepali) and numeral (ASCII/Devanagari) switches.
|
|
36
|
+
Directives: `%Y %y %m %-m %d %-d %B %b %A %a %j %%`.
|
|
37
|
+
- `django_bikram.django.fields.BSDateField`: a `models.DateField` subclass that
|
|
38
|
+
stores a native Gregorian `date` and exposes a `BSDate`, preserving indexes,
|
|
39
|
+
range queries, ordering, aggregation and DB-side date functions.
|
|
40
|
+
- `django_bikram.django.forms`: `BSDateField` form field and `BSDateInput` widget.
|
|
41
|
+
- `django_bikram.django.drf`: DRF serializer field, import-guarded as an optional
|
|
42
|
+
extra, plus `register_serializer_field()` for `ModelSerializer`.
|
|
43
|
+
- `django_bikram.django.lookups`: `bs_year_q` / `bs_month_q` / `bs_year_bounds` /
|
|
44
|
+
`bs_month_bounds` — index-friendly half-open range helpers.
|
|
45
|
+
- Migration serializer for `BSDate`, so `default=BSDate(...)` works.
|
|
46
|
+
- `py.typed`: the package ships inline type information and passes `mypy --strict`.
|
|
47
|
+
- Bilingual documentation: English and Nepali README plus a Nepali quickstart.
|
|
48
|
+
|
|
49
|
+
### Deliberately not included
|
|
50
|
+
|
|
51
|
+
- `__bs_year` / `__bs_month` query transforms. See the README section
|
|
52
|
+
"Why there is no `__bs_year` lookup" — the range helpers are exact and use
|
|
53
|
+
the index; a transform would not.
|
|
54
|
+
- Bikram Sambat time/datetime types. The calendar defines days, not clocks;
|
|
55
|
+
use an ordinary `DateTimeField` for instants.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Contributing to django-bikram
|
|
2
|
+
|
|
3
|
+
Thanks for helping. The bar here is high on purpose: this is a calendar library,
|
|
4
|
+
and a wrong month length is a silent, hard-to-notice bug.
|
|
5
|
+
|
|
6
|
+
## Development setup
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
git clone https://github.com/anishbhimgc/django-bikram
|
|
10
|
+
cd django-bikram
|
|
11
|
+
python -m venv .venv && source .venv/bin/activate
|
|
12
|
+
pip install -e ".[dev]"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## The checks CI runs (run them before you push)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pytest # the full suite
|
|
19
|
+
ruff check django_bikram/ # style + lint
|
|
20
|
+
mypy django_bikram/ # strict typing
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
CI additionally runs the test suite across Python 3.10–3.13 and Django 4.2 / 5.1
|
|
24
|
+
/ 5.2, verifies the docstring examples, and validates the built package metadata.
|
|
25
|
+
|
|
26
|
+
## Touching the calendar data
|
|
27
|
+
|
|
28
|
+
`django_bikram/calendar_data.py` is the correctness core.
|
|
29
|
+
|
|
30
|
+
- **Verified years** (`VERIFIED_BS_MONTH_DAYS`) may only be added when a year is
|
|
31
|
+
corroborated by **at least two independent published sources**, and must pass
|
|
32
|
+
the invariants in `tests/test_calendar_data.py` (twelve months, 365/366 days,
|
|
33
|
+
no filler tail).
|
|
34
|
+
- **Do not** promote predicted (provisional) data into the verified table. The
|
|
35
|
+
predictor in `django_bikram/predict.py` is ~87% accurate per month (see its
|
|
36
|
+
`validate()`); that is a planning aid, never a source of verified dates.
|
|
37
|
+
|
|
38
|
+
## Releasing (maintainers)
|
|
39
|
+
|
|
40
|
+
Publishing uses **PyPI Trusted Publishing** — no tokens are stored.
|
|
41
|
+
|
|
42
|
+
One-time PyPI setup:
|
|
43
|
+
|
|
44
|
+
1. On https://pypi.org, register a *pending publisher* under the project
|
|
45
|
+
(or the account): PyPI → *Your projects* → *Publishing* → add a GitHub
|
|
46
|
+
publisher with owner `anishbhimgc`, repo `django-bikram`, workflow
|
|
47
|
+
`publish.yml`, environment `pypi`.
|
|
48
|
+
|
|
49
|
+
Each release:
|
|
50
|
+
|
|
51
|
+
1. Bump `version` in `pyproject.toml` and move the `CHANGELOG.md` entries from
|
|
52
|
+
*Unreleased* into a dated version section.
|
|
53
|
+
2. Commit, tag (`git tag v0.1.0 && git push --tags`).
|
|
54
|
+
3. Create a GitHub Release for that tag. The `publish.yml` workflow builds,
|
|
55
|
+
checks, and uploads to PyPI automatically.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 django-bikram contributors
|
|
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.
|