convertdate 2.4.0__tar.gz → 2.5.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.
- {convertdate-2.4.0/src/convertdate.egg-info → convertdate-2.5.0}/PKG-INFO +20 -12
- convertdate-2.5.0/pyproject.toml +96 -0
- convertdate-2.5.0/setup.cfg +4 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/__init__.py +25 -24
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/coptic.py +2 -2
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/hebrew.py +9 -1
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/islamic.py +3 -3
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/mayan.py +3 -1
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/ordinal.py +10 -3
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/utils.py +2 -4
- {convertdate-2.4.0 → convertdate-2.5.0/src/convertdate.egg-info}/PKG-INFO +20 -12
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate.egg-info/SOURCES.txt +15 -4
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate.egg-info/requires.txt +2 -2
- convertdate-2.5.0/tests/test_armenian.py +123 -0
- convertdate-2.5.0/tests/test_bahai.py +207 -0
- convertdate-2.5.0/tests/test_coptic.py +68 -0
- convertdate-2.5.0/tests/test_french_republican.py +325 -0
- convertdate-2.5.0/tests/test_general.py +151 -0
- convertdate-2.5.0/tests/test_gregorian.py +100 -0
- convertdate-2.5.0/tests/test_holidays.py +317 -0
- convertdate-2.5.0/tests/test_indian_civil.py +47 -0
- convertdate-2.5.0/tests/test_julian.py +53 -0
- convertdate-2.5.0/tests/test_mayan.py +89 -0
- convertdate-2.5.0/tests/test_ordinal.py +88 -0
- convertdate-2.5.0/tests/test_persian.py +108 -0
- convertdate-2.5.0/tests/test_positivist.py +94 -0
- convertdate-2.5.0/tests/test_utils.py +23 -0
- convertdate-2.4.0/pyproject.toml +0 -29
- convertdate-2.4.0/setup.cfg +0 -57
- convertdate-2.4.0/setup.py +0 -11
- convertdate-2.4.0/src/convertdate.egg-info/entry_points.txt +0 -3
- {convertdate-2.4.0 → convertdate-2.5.0}/LICENSE +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/README.md +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/armenian.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/bahai.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/data/__init__.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/data/french_republican_days.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/data/positivist.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/daycount.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/dublin.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/french_republican.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/gregorian.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/holidays.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/indian_civil.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/iso.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/julian.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/julianday.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/persian.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate/positivist.py +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate.egg-info/dependency_links.txt +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate.egg-info/top_level.txt +0 -0
- {convertdate-2.4.0 → convertdate-2.5.0}/src/convertdate.egg-info/zip-safe +0 -0
|
@@ -1,29 +1,39 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: convertdate
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: Converts between Gregorian dates and other calendar systems
|
|
5
|
-
|
|
6
|
-
Author: Neil Freeman
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Author: Phil Schwartz
|
|
6
|
+
Author-email: Neil Freeman <contact@fakeisthenewreal.org>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/fitnr/convertdate
|
|
9
9
|
Keywords: calendar,date,time
|
|
10
|
-
Platform: UNKNOWN
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
10
|
Classifier: Natural Language :: English
|
|
13
11
|
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
15
12
|
Classifier: Programming Language :: Python :: 3.8
|
|
16
13
|
Classifier: Programming Language :: Python :: 3.9
|
|
17
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
18
|
Classifier: Topic :: Religion
|
|
19
19
|
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
20
20
|
Classifier: Operating System :: OS Independent
|
|
21
21
|
Requires-Python: <4,>=3.7
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: pymeeus<=1,>=0.3.13
|
|
23
25
|
Provides-Extra: tests
|
|
26
|
+
Requires-Dist: coverage[toml]; extra == "tests"
|
|
27
|
+
Requires-Dist: pylint; extra == "tests"
|
|
24
28
|
Provides-Extra: docs
|
|
29
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
30
|
+
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
31
|
+
Requires-Dist: myst_parser; extra == "docs"
|
|
25
32
|
Provides-Extra: dev
|
|
26
|
-
|
|
33
|
+
Requires-Dist: build; extra == "dev"
|
|
34
|
+
Requires-Dist: black; extra == "dev"
|
|
35
|
+
Requires-Dist: isort; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
27
37
|
|
|
28
38
|
convertdate
|
|
29
39
|
===========
|
|
@@ -275,5 +285,3 @@ Other utility functions:
|
|
|
275
285
|
- previous\_weekday
|
|
276
286
|
- previous\_or\_current\_weekday
|
|
277
287
|
|
|
278
|
-
|
|
279
|
-
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# This file is part of convertdate.
|
|
2
|
+
# http://github.com/fitnr/convertdate
|
|
3
|
+
# Licensed under the MIT license:
|
|
4
|
+
# http://opensource.org/licenses/MIT
|
|
5
|
+
# Copyright (c) 2020-2, fitnr <fitnr@fakeisthenewreal>
|
|
6
|
+
[project]
|
|
7
|
+
name = "convertdate"
|
|
8
|
+
description = "Converts between Gregorian dates and other calendar systems"
|
|
9
|
+
authors = [
|
|
10
|
+
{name = "Neil Freeman", email = "contact@fakeisthenewreal.org"},
|
|
11
|
+
{name = "Phil Schwartz"}
|
|
12
|
+
]
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
license = "MIT"
|
|
15
|
+
license-files = ["LICENSE"]
|
|
16
|
+
keywords = ["calendar", "date", "time"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Natural Language :: English",
|
|
19
|
+
"Programming Language :: Python",
|
|
20
|
+
"Programming Language :: Python :: 3.8",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Topic :: Religion",
|
|
27
|
+
"Topic :: Scientific/Engineering :: Astronomy",
|
|
28
|
+
"Operating System :: OS Independent",
|
|
29
|
+
]
|
|
30
|
+
requires-python = ">= 3.7, <4"
|
|
31
|
+
dependencies = [
|
|
32
|
+
"pymeeus>=0.3.13, <=1",
|
|
33
|
+
]
|
|
34
|
+
dynamic = ["version"]
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.dynamic]
|
|
37
|
+
version = { attr = "convertdate.__version__" }
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
Homepage = "https://github.com/fitnr/convertdate"
|
|
41
|
+
|
|
42
|
+
[project.optional-dependencies]
|
|
43
|
+
tests = [
|
|
44
|
+
"coverage[toml]",
|
|
45
|
+
"pylint",
|
|
46
|
+
]
|
|
47
|
+
docs = [
|
|
48
|
+
"sphinx",
|
|
49
|
+
"sphinx_rtd_theme",
|
|
50
|
+
"myst_parser",
|
|
51
|
+
]
|
|
52
|
+
dev = [
|
|
53
|
+
"build",
|
|
54
|
+
"black",
|
|
55
|
+
"isort",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[build-system]
|
|
59
|
+
requires = ["setuptools>=61.1.1", "wheel"]
|
|
60
|
+
build-backend = "setuptools.build_meta"
|
|
61
|
+
|
|
62
|
+
[tool.setuptools]
|
|
63
|
+
zip-safe = true
|
|
64
|
+
packages = [
|
|
65
|
+
"convertdate",
|
|
66
|
+
"convertdate.data",
|
|
67
|
+
]
|
|
68
|
+
package-dir = {"" = "src"}
|
|
69
|
+
|
|
70
|
+
[tool.black]
|
|
71
|
+
line-length = 120
|
|
72
|
+
target-version = ["py39"]
|
|
73
|
+
include = "py$"
|
|
74
|
+
skip-string-normalization = true
|
|
75
|
+
|
|
76
|
+
[tool.pylint.master]
|
|
77
|
+
fail-under = "8.77"
|
|
78
|
+
|
|
79
|
+
[tool.pylint.messages_control]
|
|
80
|
+
disable = [
|
|
81
|
+
"invalid-name",
|
|
82
|
+
"duplicate-code"
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
[tool.pylint.format]
|
|
86
|
+
max-line-length = 120
|
|
87
|
+
|
|
88
|
+
[tool.isort]
|
|
89
|
+
line_length = 120
|
|
90
|
+
|
|
91
|
+
[tool.ruff]
|
|
92
|
+
target-version = "py39"
|
|
93
|
+
line-length = 120
|
|
94
|
+
|
|
95
|
+
[tool.ruff.lint]
|
|
96
|
+
select = ["I", "E"]
|
|
@@ -18,47 +18,48 @@ which was developed by John Walker.
|
|
|
18
18
|
The algorithms are believed to be derived from: Meeus, Jean. `Astronomical Algorithms`,
|
|
19
19
|
Richmond: Willmann-Bell, 1991 (ISBN 0-943396-35-2)
|
|
20
20
|
"""
|
|
21
|
-
from . import
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
from . import (
|
|
22
|
+
armenian,
|
|
23
|
+
bahai,
|
|
24
|
+
coptic,
|
|
25
|
+
daycount,
|
|
26
|
+
dublin,
|
|
27
|
+
french_republican,
|
|
28
|
+
gregorian,
|
|
29
|
+
hebrew,
|
|
30
|
+
holidays,
|
|
31
|
+
indian_civil,
|
|
32
|
+
islamic,
|
|
33
|
+
iso,
|
|
34
|
+
julian,
|
|
35
|
+
julianday,
|
|
36
|
+
mayan,
|
|
37
|
+
ordinal,
|
|
38
|
+
persian,
|
|
39
|
+
positivist,
|
|
40
|
+
utils,
|
|
41
|
+
)
|
|
40
42
|
|
|
41
|
-
__version__ = '2.
|
|
43
|
+
__version__ = '2.5.0'
|
|
42
44
|
|
|
43
45
|
__all__ = [
|
|
44
|
-
'holidays',
|
|
45
46
|
'armenian',
|
|
46
47
|
'bahai',
|
|
47
48
|
'coptic',
|
|
48
|
-
'dublin',
|
|
49
49
|
'daycount',
|
|
50
|
+
'dublin',
|
|
50
51
|
'french_republican',
|
|
51
52
|
'gregorian',
|
|
52
53
|
'hebrew',
|
|
54
|
+
'holidays',
|
|
53
55
|
'indian_civil',
|
|
54
56
|
'islamic',
|
|
55
57
|
'iso',
|
|
56
58
|
'julian',
|
|
57
59
|
'julianday',
|
|
58
60
|
'mayan',
|
|
61
|
+
'ordinal',
|
|
59
62
|
'persian',
|
|
60
63
|
'positivist',
|
|
61
|
-
'mayan',
|
|
62
|
-
'ordinal',
|
|
63
64
|
'utils',
|
|
64
65
|
]
|
|
@@ -13,6 +13,7 @@ of the ancient Egyptian calendar.
|
|
|
13
13
|
It consists of twelve months of 30 days, followed by a "little month" of five days
|
|
14
14
|
(six in leap years).
|
|
15
15
|
"""
|
|
16
|
+
|
|
16
17
|
from math import floor
|
|
17
18
|
|
|
18
19
|
from . import gregorian
|
|
@@ -49,8 +50,7 @@ def to_jd(year, month, day):
|
|
|
49
50
|
|
|
50
51
|
def from_jd(jdc):
|
|
51
52
|
"Create a new date from a Julian date."
|
|
52
|
-
|
|
53
|
-
year = floor((cdc - floor((cdc + 366) / 1461)) / 365) + 1
|
|
53
|
+
year = floor((4 * floor(jdc - EPOCH) + 1463) / 1461)
|
|
54
54
|
|
|
55
55
|
yday = jdc - to_jd(year, 1, 1)
|
|
56
56
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# Licensed under the MIT license:
|
|
5
5
|
# http://opensource.org/licenses/MIT
|
|
6
6
|
# Copyright (c) 2016, fitnr <fitnr@fakeisthenewreal>
|
|
7
|
+
import warnings
|
|
7
8
|
from math import floor
|
|
8
9
|
|
|
9
10
|
from . import gregorian
|
|
@@ -108,7 +109,8 @@ def year_days(year):
|
|
|
108
109
|
return to_jd(year + 1, 7, 1) - to_jd(year, 7, 1)
|
|
109
110
|
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
|
|
113
|
+
def month_length(year, month):
|
|
112
114
|
'''How many days are in a given month of a given year'''
|
|
113
115
|
if month > VEADAR:
|
|
114
116
|
raise ValueError("Incorrect month index")
|
|
@@ -132,6 +134,12 @@ def month_days(year, month):
|
|
|
132
134
|
# Nope, it's a 30 day month
|
|
133
135
|
return 30
|
|
134
136
|
|
|
137
|
+
def month_days(year, month):
|
|
138
|
+
# retain for backwards compatibility, but warn that this is deprecated
|
|
139
|
+
warnings.warn("month_days is deprecated, please use month_length",
|
|
140
|
+
DeprecationWarning, stacklevel=2)
|
|
141
|
+
return month_length(year, month)
|
|
142
|
+
|
|
135
143
|
|
|
136
144
|
def to_jd(year, month, day):
|
|
137
145
|
months = year_months(year)
|
|
@@ -288,7 +288,9 @@ def next_tzolkin(tzolkin, jd):
|
|
|
288
288
|
|
|
289
289
|
|
|
290
290
|
def next_tzolkin_haab(tzolkin, haab, jd):
|
|
291
|
-
'''
|
|
291
|
+
'''Find the next occurence of a haab-tzolk'in combination.
|
|
292
|
+
|
|
293
|
+
Requires a Julian day count as the starting place for the search.'''
|
|
292
294
|
# get H & T of input jd, and their place in the 18,980 day cycle
|
|
293
295
|
haabcount = _haab_count(*to_haab(jd))
|
|
294
296
|
haab_desired_count = _haab_count(*haab)
|
|
@@ -22,9 +22,16 @@ def to_jd(year, dayofyear):
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def from_jd(jd):
|
|
25
|
-
'''Convert a Julian day count to an ordinal date.
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
'''Convert a Julian day count to an ordinal date.
|
|
26
|
+
|
|
27
|
+
The day of year is derived from the Gregorian date rather than the raw
|
|
28
|
+
``jd``. Both ``to_jd`` values carry the same half-day offset, so their
|
|
29
|
+
difference is an exact whole number of days; subtracting ``jd`` directly
|
|
30
|
+
leaves a ``.5`` remainder that ``round`` pushes the wrong way (e.g.
|
|
31
|
+
``365.5`` -> ``366``), reporting a non-existent day 366 in common years.
|
|
32
|
+
'''
|
|
33
|
+
year, month, day = gregorian.from_jd(jd)
|
|
34
|
+
return year, int(gregorian.to_jd(year, month, day) - gregorian.to_jd(year, 1, 1)) + 1
|
|
28
35
|
|
|
29
36
|
|
|
30
37
|
def from_gregorian(year, month, day):
|
|
@@ -74,14 +74,12 @@ def n_weeks(weekday, jd, nthweek):
|
|
|
74
74
|
|
|
75
75
|
|
|
76
76
|
def monthcalendarhelper(start_weekday, month_length):
|
|
77
|
-
end_weekday = start_weekday + (month_length - 1) % 7
|
|
78
77
|
|
|
79
78
|
lpad = (start_weekday + 1) % 7
|
|
80
|
-
rpad = (5 - end_weekday % 7) % 6
|
|
81
79
|
|
|
82
|
-
days = [None] * lpad + list(range(1, 1 + month_length)) +
|
|
80
|
+
days = [None] * lpad + list(range(1, 1 + month_length)) + 7 * [None]
|
|
83
81
|
|
|
84
|
-
return [days[i : i + 7] for i in range(0,
|
|
82
|
+
return [days[i : i + 7] for i in range(0, lpad + month_length, 7)]
|
|
85
83
|
|
|
86
84
|
|
|
87
85
|
def nth_day_of_month(n, weekday, month, year):
|
|
@@ -1,29 +1,39 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: convertdate
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5.0
|
|
4
4
|
Summary: Converts between Gregorian dates and other calendar systems
|
|
5
|
-
|
|
6
|
-
Author: Neil Freeman
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Author: Phil Schwartz
|
|
6
|
+
Author-email: Neil Freeman <contact@fakeisthenewreal.org>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/fitnr/convertdate
|
|
9
9
|
Keywords: calendar,date,time
|
|
10
|
-
Platform: UNKNOWN
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
10
|
Classifier: Natural Language :: English
|
|
13
11
|
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
15
12
|
Classifier: Programming Language :: Python :: 3.8
|
|
16
13
|
Classifier: Programming Language :: Python :: 3.9
|
|
17
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
18
|
Classifier: Topic :: Religion
|
|
19
19
|
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
20
20
|
Classifier: Operating System :: OS Independent
|
|
21
21
|
Requires-Python: <4,>=3.7
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: pymeeus<=1,>=0.3.13
|
|
23
25
|
Provides-Extra: tests
|
|
26
|
+
Requires-Dist: coverage[toml]; extra == "tests"
|
|
27
|
+
Requires-Dist: pylint; extra == "tests"
|
|
24
28
|
Provides-Extra: docs
|
|
29
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
30
|
+
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
31
|
+
Requires-Dist: myst_parser; extra == "docs"
|
|
25
32
|
Provides-Extra: dev
|
|
26
|
-
|
|
33
|
+
Requires-Dist: build; extra == "dev"
|
|
34
|
+
Requires-Dist: black; extra == "dev"
|
|
35
|
+
Requires-Dist: isort; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
27
37
|
|
|
28
38
|
convertdate
|
|
29
39
|
===========
|
|
@@ -275,5 +285,3 @@ Other utility functions:
|
|
|
275
285
|
- previous\_weekday
|
|
276
286
|
- previous\_or\_current\_weekday
|
|
277
287
|
|
|
278
|
-
|
|
279
|
-
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
LICENSE
|
|
2
2
|
README.md
|
|
3
3
|
pyproject.toml
|
|
4
|
-
setup.cfg
|
|
5
|
-
setup.py
|
|
6
4
|
src/convertdate/__init__.py
|
|
7
5
|
src/convertdate/armenian.py
|
|
8
6
|
src/convertdate/bahai.py
|
|
@@ -26,10 +24,23 @@ src/convertdate/utils.py
|
|
|
26
24
|
src/convertdate.egg-info/PKG-INFO
|
|
27
25
|
src/convertdate.egg-info/SOURCES.txt
|
|
28
26
|
src/convertdate.egg-info/dependency_links.txt
|
|
29
|
-
src/convertdate.egg-info/entry_points.txt
|
|
30
27
|
src/convertdate.egg-info/requires.txt
|
|
31
28
|
src/convertdate.egg-info/top_level.txt
|
|
32
29
|
src/convertdate.egg-info/zip-safe
|
|
33
30
|
src/convertdate/data/__init__.py
|
|
34
31
|
src/convertdate/data/french_republican_days.py
|
|
35
|
-
src/convertdate/data/positivist.py
|
|
32
|
+
src/convertdate/data/positivist.py
|
|
33
|
+
tests/test_armenian.py
|
|
34
|
+
tests/test_bahai.py
|
|
35
|
+
tests/test_coptic.py
|
|
36
|
+
tests/test_french_republican.py
|
|
37
|
+
tests/test_general.py
|
|
38
|
+
tests/test_gregorian.py
|
|
39
|
+
tests/test_holidays.py
|
|
40
|
+
tests/test_indian_civil.py
|
|
41
|
+
tests/test_julian.py
|
|
42
|
+
tests/test_mayan.py
|
|
43
|
+
tests/test_ordinal.py
|
|
44
|
+
tests/test_persian.py
|
|
45
|
+
tests/test_positivist.py
|
|
46
|
+
tests/test_utils.py
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import time
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
from convertdate import julianday
|
|
6
|
+
from convertdate.armenian import (
|
|
7
|
+
_valid_date,
|
|
8
|
+
from_gregorian,
|
|
9
|
+
from_jd,
|
|
10
|
+
from_julian,
|
|
11
|
+
leap,
|
|
12
|
+
month_length,
|
|
13
|
+
to_gregorian,
|
|
14
|
+
to_jd,
|
|
15
|
+
to_julian,
|
|
16
|
+
tostring,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
from . import CalTestCase
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TestArmenian(CalTestCase):
|
|
23
|
+
def setUp(self):
|
|
24
|
+
self.now = time.localtime()
|
|
25
|
+
self.today = julianday.from_gregorian(self.now[0], self.now[1], self.now[2])
|
|
26
|
+
|
|
27
|
+
def testValidDate(self):
|
|
28
|
+
self.assertTrue(_valid_date(1, 1, 1))
|
|
29
|
+
|
|
30
|
+
self.assertTrue(_valid_date(533, 1, 1, method="sarkawag"))
|
|
31
|
+
|
|
32
|
+
with self.assertRaises(ValueError):
|
|
33
|
+
_valid_date(401, 1, 1, method="sarkawag")
|
|
34
|
+
|
|
35
|
+
with self.assertRaises(ValueError):
|
|
36
|
+
_valid_date(30, 4, 31)
|
|
37
|
+
|
|
38
|
+
with self.assertRaises(ValueError):
|
|
39
|
+
_valid_date(536, 13, 6)
|
|
40
|
+
|
|
41
|
+
with self.assertRaises(ValueError):
|
|
42
|
+
from_jd(1.5)
|
|
43
|
+
|
|
44
|
+
self.assertTrue(_valid_date(536, 13, 6, method="sarkawag"))
|
|
45
|
+
|
|
46
|
+
def testReflexive(self):
|
|
47
|
+
self.assertEqual(self.today, to_jd(*from_jd(self.today)))
|
|
48
|
+
self.assertEqual(self.today, to_jd(*from_jd(self.today, "sarkawag"), method="sarkawag"))
|
|
49
|
+
for jd in range(2159677, 2488395, 2000):
|
|
50
|
+
jd = jd + 0.5
|
|
51
|
+
self.assertEqual(jd, to_jd(*from_jd(jd)))
|
|
52
|
+
self.assertEqual(jd, to_jd(*from_jd(jd, "sarkawag"), method="sarkawag"))
|
|
53
|
+
|
|
54
|
+
def testLeap(self):
|
|
55
|
+
self.assertEqual(True, leap(600))
|
|
56
|
+
self.assertEqual(False, leap(601))
|
|
57
|
+
|
|
58
|
+
def testGregorian(self):
|
|
59
|
+
self.assertEqual((2019, 11, 3), to_gregorian(1469, 4, 14))
|
|
60
|
+
self.assertEqual((1469, 4, 14), from_gregorian(2019, 11, 3))
|
|
61
|
+
|
|
62
|
+
def testMonthLength(self):
|
|
63
|
+
self.assertEqual(30, month_length(600, 1))
|
|
64
|
+
self.assertEqual(5, month_length(600, 13))
|
|
65
|
+
self.assertEqual(6, month_length(600, 13, "sarkawag"))
|
|
66
|
+
|
|
67
|
+
def testJulian(self):
|
|
68
|
+
cases = [
|
|
69
|
+
# first date of the calendar
|
|
70
|
+
[(1, 1, 1), (552, 7, 11)],
|
|
71
|
+
# last day of the year
|
|
72
|
+
[(1, 13, 5), (553, 7, 10)],
|
|
73
|
+
# leap year moves the calendar
|
|
74
|
+
[(4, 13, 5), (556, 7, 9)],
|
|
75
|
+
[(5, 1, 1), (556, 7, 10)],
|
|
76
|
+
# check month boundaries for an entire year
|
|
77
|
+
[(420, 1, 1), (971, 3, 29)],
|
|
78
|
+
[(420, 1, 30), (971, 4, 27)],
|
|
79
|
+
[(420, 2, 1), (971, 4, 28)],
|
|
80
|
+
[(420, 2, 30), (971, 5, 27)],
|
|
81
|
+
[(420, 3, 1), (971, 5, 28)],
|
|
82
|
+
[(420, 3, 30), (971, 6, 26)],
|
|
83
|
+
[(420, 4, 1), (971, 6, 27)],
|
|
84
|
+
[(420, 4, 30), (971, 7, 26)],
|
|
85
|
+
[(420, 5, 1), (971, 7, 27)],
|
|
86
|
+
[(420, 5, 30), (971, 8, 25)],
|
|
87
|
+
[(420, 6, 1), (971, 8, 26)],
|
|
88
|
+
[(420, 6, 30), (971, 9, 24)],
|
|
89
|
+
[(420, 7, 1), (971, 9, 25)],
|
|
90
|
+
[(420, 7, 30), (971, 10, 24)],
|
|
91
|
+
[(420, 8, 1), (971, 10, 25)],
|
|
92
|
+
[(420, 8, 30), (971, 11, 23)],
|
|
93
|
+
[(420, 9, 1), (971, 11, 24)],
|
|
94
|
+
[(420, 9, 30), (971, 12, 23)],
|
|
95
|
+
[(420, 10, 1), (971, 12, 24)],
|
|
96
|
+
[(420, 10, 30), (972, 1, 22)],
|
|
97
|
+
[(420, 11, 1), (972, 1, 23)],
|
|
98
|
+
[(420, 11, 30), (972, 2, 21)],
|
|
99
|
+
[(420, 12, 1), (972, 2, 22)],
|
|
100
|
+
[(420, 12, 30), (972, 3, 22)],
|
|
101
|
+
[(420, 13, 1), (972, 3, 23)],
|
|
102
|
+
[(420, 13, 5), (972, 3, 27)],
|
|
103
|
+
# check month boundaries around Julian leap year
|
|
104
|
+
[(512, 13, 1), (1064, 2, 29)],
|
|
105
|
+
[(512, 13, 2), (1064, 3, 1)],
|
|
106
|
+
[(513, 1, 1), (1064, 3, 5)],
|
|
107
|
+
# check the two calendars in 1084
|
|
108
|
+
[(533, 6, 15), (1084, 8, 11)],
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
for a, j in cases:
|
|
112
|
+
self.assertEqual(a, from_julian(*j))
|
|
113
|
+
|
|
114
|
+
for a, j in cases:
|
|
115
|
+
self.assertEqual(j, to_julian(*a))
|
|
116
|
+
|
|
117
|
+
self.assertEqual((533, 1, 1), from_julian(1084, 8, 11, method="sarkawag"))
|
|
118
|
+
self.assertEqual((533, 13, 5), from_julian(1085, 8, 10, method="sarkawag"))
|
|
119
|
+
self.assertEqual((536, 13, 6), from_julian(1088, 8, 10, method="sarkawag"))
|
|
120
|
+
self.assertEqual((537, 1, 1), from_julian(1088, 8, 11, method="sarkawag"))
|
|
121
|
+
|
|
122
|
+
def testTostring(self):
|
|
123
|
+
self.assertEqual('14 trē 1469', tostring(1469, 4, 14))
|