Hello community, here is the log from the commit of package python-convertdate for openSUSE:Factory checked in at 2020-04-07 10:21:05 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-convertdate (Old) and /work/SRC/openSUSE:Factory/.python-convertdate.new.3248 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-convertdate" Tue Apr 7 10:21:05 2020 rev:4 rq:790809 version:2.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-convertdate/python-convertdate.changes 2019-11-04 17:06:44.340282448 +0100 +++ /work/SRC/openSUSE:Factory/.python-convertdate.new.3248/python-convertdate.changes 2020-04-07 10:21:17.641827307 +0200 @@ -1,0 +2,9 @@ +Wed Apr 1 12:16:15 UTC 2020 - Marketa Calabkova <[email protected]> + +- update to 2.2.0 + * Repair Bahai intercalary days bug (#13, thanks @bchurchill) + * Replace pyephem, which is now in maintenance mode, with pymeeus. + * Remove shebangs and regularize licenses (thanks @fabaff) + * Convert readme to ascii (#16) + +------------------------------------------------------------------- Old: ---- v2.1.3.tar.gz New: ---- v2.2.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-convertdate.spec ++++++ --- /var/tmp/diff_new_pack.RnzgOL/_old 2020-04-07 10:21:18.189827917 +0200 +++ /var/tmp/diff_new_pack.RnzgOL/_new 2020-04-07 10:21:18.193827922 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-convertdate # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-convertdate -Version: 2.1.3 +Version: 2.2.0 Release: 0 Summary: Module for date conversions from and to Gregorian calendar License: MIT @@ -28,11 +28,11 @@ BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-ephem >= 3.7.5.3 +Requires: python-PyMeeus >= 0.3.6 Requires: python-pytz >= 2014.10 BuildArch: noarch # SECTION test requirements -BuildRequires: %{python_module ephem >= 3.7.5.3} +BuildRequires: %{python_module PyMeeus >= 0.3.6} BuildRequires: %{python_module pytz >= 2014.10} # /SECTION %python_subpackages @@ -59,7 +59,7 @@ %python_exec setup.py test %files %{python_files} -%doc README.rst +%doc README.md %license LICENSE %{python_sitelib}/* ++++++ v2.1.3.tar.gz -> v2.2.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/.gitignore new/convertdate-2.2.0/.gitignore --- old/convertdate-2.1.3/.gitignore 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/.gitignore 2019-10-26 19:46:45.000000000 +0200 @@ -15,3 +15,4 @@ .tox .eggs py35 +__pycache__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/.travis.yml new/convertdate-2.2.0/.travis.yml --- old/convertdate-2.1.3/.travis.yml 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/.travis.yml 2019-10-26 19:46:45.000000000 +0200 @@ -11,10 +11,10 @@ python: - 2.7 - - 3.3 - 3.4 - 3.5 - 3.6 + - 3.8 - pypy - pypy3 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/HISTORY.rst new/convertdate-2.2.0/HISTORY.rst --- old/convertdate-2.1.3/HISTORY.rst 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/HISTORY.rst 2019-10-26 19:46:45.000000000 +0200 @@ -1,6 +1,14 @@ History ------- +2.2.0 +----- + +* Repair Bahai intercalary days bug (#13, thanks @bchurchill) +* Replace pyephem, which is now in maintenance mode, with pymeeus. +* Remove shebangs and regularize licenses (thanks @fabaff) +* Convert readme to ascii (#16) + 2.1.3 ----- * Bump requirements diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/MANIFEST.in new/convertdate-2.2.0/MANIFEST.in --- old/convertdate-2.1.3/MANIFEST.in 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/MANIFEST.in 2019-10-26 19:46:45.000000000 +0200 @@ -1,2 +1,3 @@ include LICENSE include HISTORY.rst +include README.md diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/Makefile new/convertdate-2.2.0/Makefile --- old/convertdate-2.1.3/Makefile 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/Makefile 2019-10-26 19:46:45.000000000 +0200 @@ -1,7 +1,7 @@ # This file is part of convertdate. # http://github.com/fitnr/convertdate -# Licensed under the GPL-v3.0 license: +# Licensed under the MIT license: # http://opensource.org/licenses/MIT # Copyright (c) 2016, fitnr <fitnr@fakeisthenewreal> @@ -10,8 +10,8 @@ coverage report coverage html -deploy: README.rst +deploy: git push; git push --tags rm -rf dist build - python3.5 setup.py sdist bdist_wheel --universal + python setup.py sdist bdist_wheel --universal twine upload dist/* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/README.md new/convertdate-2.2.0/README.md --- old/convertdate-2.1.3/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/convertdate-2.2.0/README.md 2019-10-26 19:46:45.000000000 +0200 @@ -0,0 +1,223 @@ +convertdate +=========== + +The convertdate package was originally developed as "[Python Date +Utils](http://sourceforge.net/projects/pythondateutil/)" by Phil +Schwartz. It had been significantly updated and expanded. + +Available calendars: + +- Bahai +- Coptic (Alexandrian) +- French Republican +- Gregorian +- Hebrew +- Indian Civil +- Islamic +- Julian +- Mayan +- Persian +- Positivist +- Mayan +- ISO +- Ordinal (day of year) +- Dublin day count +- Julian day count + +The `holidays` module also provides some useful holiday-calculation, +with a focus on North American and Jewish holidays. + +Installing +---------- + +`pip install convertdate` + +Or download the package and run `python setup.py install`. + +Using +----- + + from convertdate import french_republican + from convertdate import hebrew + + french_republican.from_gregorian(2014, 10, 31) + # (223, 2, 1, 9) + + hebrew.from_gregorian(2014, 10, 31) + # (5775, 8, 7) + +Note that in some calendar systems, the day begins at sundown. +Convertdate gives the conversion for noon of the day in question. + +Each module includes a monthcalendar function, which will generate a +calender-like nested list for a year and month (each list of dates runs +from Sunday to Saturday) + + hebrew.monthcalendar(5775, 8) + # [ + # [None, None, None, None, None, None, 1], + # [2, 3, 4, 5, 6, 7, 8], + # [9, 10, 11, 12, 13, 14, 15], + # [16, 17, 18, 19, 20, 21, 22], + # [23, 24, 25, 26, 27, 28, 29] + # ] + + julian.monthcalendar(2015, 1) + # [ + # [None, None, None, 1, 2, 3, 4], + # [5, 6, 7, 8, 9, 10, 11], + # [12, 13, 14, 15, 16, 17, 18], + # [19, 20, 21, 22, 23, 24, 25], + # [26, 27, 28, 29, 30, 31, None] + # ] + +Special Options +--------------- + +### French Republican + +Leap year calculations in the French Republican calendar are a matter of +dispute. By default, `convertdate` calculates leap years using the +autumnal equinox. You can also use one of three more systematic methods +proposed over the years. + +- Romme, a co-creator of the calendar, proposed leap years in years + divisible by four, except for years divisible by 100. +- Some concordances were drawn up in the 19th century that gave leap + years every 4 years, in years that give a remainder of three when + divided by four (19, 23, 27, etc...). +- Von Mädler proposed leap years in years divisible by four, except + for years divisible by 128. + +You can specify any of these three methods with the method keyword +argument in `french_republican` conversion functions. + + from convertdate import french_republican + + # Romme's method + french_republican.to_gregorian(20, 1, 1), method='romme') + # (1811, 9, 23) + + # continuous method + french_republican.to_gregorian(20, 1, 1), method='continuous') + # (1811, 9, 24) + + # von Madler's method + french_republican.to_gregorian(20, 1, 1), method='madler') + # (1811, 9, 23) + +All the conversion methods correctly assign the leap years implemented +while calendar was in use (3, 7, 11). + +Baha'i +------ + +The Bahá'í (Badí) calendar has an intercalary period, Ayyam-i-Há, which occurs between the 18th and 19th months. +Dates in this period are returned as month 19, and the month of ‘Alá is reported as month 20. + +```python +from convertdate import bahai +# the first day of Ayyam-i-Ha: +bahai.to_gregorian(175, 19, 1) +# (2019, 2, 11) +# The first day of 'Ala: +bahai.to_gregorian(175, 20, 1) +# (2019, 3, 2) +``` + +Before the Common Era +--------------------- + +For dates before the Common Era (year 1), `convertdate` uses +astronomical notation: 1 BC is recorded as 0, 2 BC is -1, etc. This +makes arithmatic much easier at the expense of ignoring custom. + +Note that for dates before 4 CE, `convertdate` uses the [proleptic +Julian +calendar](https://en.wikipedia.org/wiki/Proleptic_Julian_calendar). The +Julian Calendar was in use from 45 BC, but before 4 CE the leap year +leap year pattern was irregular. + +The [proleptic Gregorian +calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar) is +used for dates before 1582 CE, the year of the Gregorian calendar +reform. + +Holidays +-------- + +North American holidays are the current focus of the `holidays` module, +but pull requests are welcome. + + from convertdate import holidays + + # For simplicity, functions in the holidays module return a tuple + # In the format (year, month, day) + + holidays.new_years(2014) + # (2014, 1, 1) + + holidays.memorial_day(2014) + # (2014, 5, 26) + + # USA is default + holidays.thanksgiving(2014) + # (2014, 11, 27) + + # But there is a Canadian option for some holidays + holidays.thanksgiving(2014, 'canada') + # (2014, 10, 13) + + # Mexican national holidays + holidays.natalicio_benito_juarez(2016) + # (2016, 3, 21) + + holidays.dia_revolucion(2016) + # (2016, 11, 21) + + # Some Jewish holidays are included + holidays.rosh_hashanah(2014) + +Utils +----- + +Convertdate includes some utilities for manipulating and calculating +dates. + + from convertdate import utils + + # Calculate an arbitrary day of the week + THUR = 3 + APRIL = 4 + + # 3rd Thursday in April + utils.nth_day_of_month(3, THUR, APRIL, 2014) + # (2014, 4, 17) + + utils.nth_day_of_month(5, THUR, APRIL, 2014) + # IndexError: No 5th day of month 4 + + # Use 0 for the first argument to get the last weekday of a month + utils.nth_day_of_month(0, THUR, APRIL, 2014) + # (2014, 4, 24) + +Note that when calculating weekdays, convertdate uses the convention of +the calendar and time modules: Monday is 0, Sunday is 6. + + from convertdate import gregorian + + SUN = 6 + + day = gregorian.to_jd(2014, 4, 17) + nextsunday = utils.next_weekday(SUN, day) + + gregorian.from_jd(nextsunday) + # (2014, 4, 20) + +Other utility functions: + +- nearest\_weekday +- next\_or\_current\_weekday +- previous\_weekday +- previous\_or\_current\_weekday + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/README.rst new/convertdate-2.2.0/README.rst --- old/convertdate-2.1.3/README.rst 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/README.rst 1970-01-01 01:00:00.000000000 +0100 @@ -1,210 +0,0 @@ -=========== -convertdate -=========== - -The convertdate package was originally developed as “`Python Date -Utils`_” by Phil Schwartz. It had been significantly updated and -expanded. - -Available calendars: - -- Bahai -- Coptic (Alexandrian) -- French Republican -- Gregorian -- Hebrew -- Indian Civil -- Islamic -- Julian -- Mayan -- Persian -- Positivist -- Mayan -- ISO -- Ordinal (day of year) -- Dublin day count -- Julian day count - -The ``holidays`` module also provides some useful holiday-calculation, -with a focus on North American and Jewish holidays. - -Installing ----------- - -``pip install convertdate`` - -Or download the package and run ``python setup.py install``. - -Using ------ - -:: - - from convertdate import french_republican - from convertdate import hebrew - - french_republican.from_gregorian(2014, 10, 31) - # (223, 2, 1, 9) - - hebrew.from_gregorian(2014, 10, 31) - # (5775, 8, 7) - -Note that in some calendar systems, the day begins at sundown. -Convertdate gives the conversion for noon of the day in question. - -Each module includes a monthcalendar function, which will generate a -calender-like nested list for a year and month (each list of dates runs -from Sunday to Saturday) - -:: - - hebrew.monthcalendar(5775, 8) - # [ - # [None, None, None, None, None, None, 1], - # [2, 3, 4, 5, 6, 7, 8], - # [9, 10, 11, 12, 13, 14, 15], - # [16, 17, 18, 19, 20, 21, 22], - # [23, 24, 25, 26, 27, 28, 29] - # ] - - julian.monthcalendar(2015, 1) - # [ - # [None, None, None, 1, 2, 3, 4], - # [5, 6, 7, 8, 9, 10, 11], - # [12, 13, 14, 15, 16, 17, 18], - # [19, 20, 21, 22, 23, 24, 25], - # [26, 27, 28, 29, 30, 31, None] - # ] - -Special Options ---------------- - -French Republican -~~~~~~~~~~~~~~~~~ - -Leap year calculations in the French Republican calendar are a matter of dispute. By default, ``convertdate`` calculates leap years using the autumnal equinox. You can also use one of three more systematic methods proposed over the years. - -* Romme, a co-creator of the calendar, proposed leap years in years divisible by four, except for years divisible by 100. -* Some concordances were drawn up in the 19th century that gave leap years every 4 years, in years that give a remainder of three when divided by four (19, 23, 27, etc...). -* Von Mädler proposed leap years in years divisible by four, except for years divisible by 128. - -You can specify any of these three methods with the method keyword argument in ``french_republican`` conversion functions. - -:: - - from convertdate import french_republican - - # Romme's method - french_republican.to_gregorian(20, 1, 1), method='romme') - # (1811, 9, 23) - - # continuous method - french_republican.to_gregorian(20, 1, 1), method='continuous') - # (1811, 9, 24) - - # von Mädler's method - french_republican.to_gregorian(20, 1, 1), method='madler') - # (1811, 9, 23) - -All the conversion methods correctly assign the leap years implemented while calendar was in use (3, 7, 11). - -Before the Common Era ---------------------- - -For dates before the Common Era (year 1), ``convertdate`` uses -astronomical notation: 1 BC is recorded as 0, 2 BC is -1, etc. This -makes arithmatic much easier at the expense of ignoring custom. - -Note that for dates before 4 CE, ``convertdate`` uses the `proleptic -Julian calendar`_. The Julian Calendar was in use from 45 BC, but before 4 CE the leap year leap year pattern was irregular. - -The `proleptic Gregorian calendar`_ is used for dates before 1582 CE, -the year of the Gregorian calendar reform. - -Holidays --------- - -North American holidays are the current focus of the ``holidays`` -module, but pull requests are welcome. - -:: - - from convertdate import holidays - - # For simplicity, functions in the holidays module return a tuple - # In the format (year, month, day) - - holidays.new_years(2014) - # (2014, 1, 1) - - holidays.memorial_day(2014) - # (2014, 5, 26) - - # USA is default - holidays.thanksgiving(2014) - # (2014, 11, 27) - - # But there is a Canadian option for some holidays - holidays.thanksgiving(2014, 'canada') - # (2014, 10, 13) - - # Mexican national holidays - holidays.natalicio_benito_juarez(2016) - # (2016, 3, 21) - - holidays.dia_revolucion(2016) - # (2016, 11, 21) - - # Some Jewish holidays are included - holidays.rosh_hashanah(2014) - - -Utils ------ - -Convertdate includes some utilities for manipulating and calculating -dates. - -:: - - from convertdate import utils - - # Calculate an arbitrary day of the week - THUR = 3 - APRIL = 4 - - # 3rd Thursday in April - utils.nth_day_of_month(3, THUR, APRIL, 2014) - # (2014, 4, 17) - - utils.nth_day_of_month(5, THUR, APRIL, 2014) - # IndexError: No 5th day of month 4 - - # Use 0 for the first argument to get the last weekday of a month - utils.nth_day_of_month(0, THUR, APRIL, 2014) - # (2014, 4, 24) - -Note that when calculating weekdays, convertdate uses the convention of the `calendar` and `time` modules: Monday is 0, Sunday is 6. - -:: - - from convertdate import gregorian - - SUN = 6 - - day = gregorian.to_jd(2014, 4, 17) - nextsunday = utils.next_weekday(SUN, day) - - gregorian.from_jd(nextsunday) - # (2014, 4, 20) - -Other utility functions: - -- nearest_weekday -- next_or_current_weekday -- previous_weekday -- previous_or_current_weekday - -.. _Python Date Utils: http://sourceforge.net/projects/pythondateutil/ -.. _proleptic Julian calendar: https://en.wikipedia.org/wiki/Proleptic_Julian_calendar -.. _proleptic Gregorian calendar: https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/__init__.py new/convertdate-2.2.0/convertdate/__init__.py --- old/convertdate-2.1.3/convertdate/__init__.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/__init__.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. @@ -34,7 +33,7 @@ from . import positivist from . import ordinal -__version__ = '2.1.3' +__version__ = '2.2.0' __all__ = [ 'holidays', 'bahai', 'coptic', 'dublin', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/bahai.py new/convertdate-2.2.0/convertdate/bahai.py --- old/convertdate-2.1.3/convertdate/bahai.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/bahai.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. @@ -7,14 +6,20 @@ # Licensed under the MIT license: # http://opensource.org/licenses/MIT # Copyright (c) 2016, fitnr <fitnr@fakeisthenewreal> -from math import trunc +from math import trunc, ceil from calendar import isleap +from pymeeus.Sun import Sun +from pymeeus.Epoch import Epoch +from pymeeus.Angle import Angle from . import gregorian from .utils import monthcalendarhelper, jwday + EPOCH = 2394646.5 EPOCH_GREGORIAN_YEAR = 1844 +TEHRAN = 51.4215, 35.6944 + WEEKDAYS = ("Jamál", "Kamál", "Fidál", "Idál", "Istijlál", "Istiqlál", "Jalál") MONTHS = ("Bahá", "Jalál", "Jamál", "‘Aẓamat", "Núr", "Raḥmat", "Kalimát", "Kamál", "Asmá’", @@ -26,30 +31,47 @@ "Honour", "Sovereignty", "Dominion", "Days of Há", "Loftiness") +def gregorian_nawruz(year): + ''' + Return Nawruz in the Gregorian calendar. + Returns a tuple (month, day), where month is always 3 + ''' + if year == 2059: + return 3, 20 + + # Timestamp of spring equinox. + equinox = Sun.get_equinox_solstice(year, "spring") + + # Get times of sunsets in Tehran near vernal equinox. + x, y = Angle(TEHRAN[0]), Angle(TEHRAN[1]) + days = trunc(equinox.get_date()[2]), ceil(equinox.get_date()[2]) + + for day in days: + sunset = Epoch(year, 3, day).rise_set(y, x)[1] + if sunset > equinox: + return 3, day + + def to_jd(year, month, day): '''Determine Julian day from Bahai date''' - gy = year - 1 + EPOCH_GREGORIAN_YEAR + if month <= 18: + gy = year - 1 + EPOCH_GREGORIAN_YEAR + n_month, n_day = gregorian_nawruz(gy) + return gregorian.to_jd(gy, n_month, n_day - 1) + day + (month - 1) * 19 - if month != 20: - m = 0 - else: - if isleap(gy + 1): - m = -14 - else: - m = -15 - return gregorian.to_jd(gy, 3, 20) + (19 * (month - 1)) + m + day + return to_jd(year, month - 1, day) + month_length(year, month) def from_jd(jd): '''Calculate Bahai date from Julian day''' - jd = trunc(jd) + 0.5 g = gregorian.from_jd(jd) gy = g[0] + n_month, n_day = gregorian_nawruz(gy) bstarty = EPOCH_GREGORIAN_YEAR - if jd <= gregorian.to_jd(gy, 3, 20): + if jd <= gregorian.to_jd(gy, n_month, 20): x = 1 else: x = 0 @@ -58,7 +80,7 @@ year = bys + 1 days = jd - to_jd(year, 1, 1) - bld = to_jd(year, 20, 1) + bld = to_jd(year, n_day - 1, 1) if jd >= bld: month = 20 @@ -78,14 +100,19 @@ def month_length(year, month): + gy = year + EPOCH_GREGORIAN_YEAR - 1 + if month == 19: - if isleap(year + EPOCH_GREGORIAN_YEAR): - return 5 - else: - return 4 + _, nawruz_future = gregorian_nawruz(gy + 1) + _, nawruz_past = gregorian_nawruz(gy) + length_of_year = nawruz_future + 365 - nawruz_past - else: - return 19 + if isleap(gy + 1): + length_of_year = length_of_year + 1 + + return length_of_year - 19 * 19 + + return 19 def monthcalendar(year, month): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/coptic.py new/convertdate-2.2.0/convertdate/coptic.py --- old/convertdate-2.1.3/convertdate/coptic.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/coptic.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/data/french_republican_days.py new/convertdate-2.2.0/convertdate/data/french_republican_days.py --- old/convertdate-2.1.3/convertdate/data/french_republican_days.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/data/french_republican_days.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/data/positivist.py new/convertdate-2.2.0/convertdate/data/positivist.py --- old/convertdate-2.1.3/convertdate/data/positivist.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/data/positivist.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- day_names = ( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/daycount.py new/convertdate-2.2.0/convertdate/daycount.py --- old/convertdate-2.1.3/convertdate/daycount.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/daycount.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/dublin.py new/convertdate-2.2.0/convertdate/dublin.py --- old/convertdate-2.1.3/convertdate/dublin.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/dublin.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/french_republican.py new/convertdate-2.2.0/convertdate/french_republican.py --- old/convertdate-2.1.3/convertdate/french_republican.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/french_republican.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. @@ -8,9 +7,9 @@ # http://opensource.org/licenses/MIT # Copyright (c) 2016, fitnr <fitnr@fakeisthenewreal> from math import trunc -from . import dublin, gregorian +from pymeeus.Sun import Sun +from . import gregorian from .data.french_republican_days import french_republican_days -import ephem # julian day (1792, 9, 22) EPOCH = 2375839.5 @@ -38,36 +37,37 @@ LEAP_CYCLE_DAYS = 1461. # 365 * 4 + 1 LEAP_CYCLE_YEARS = 4. -# methods: -# 4 (concordance rule): leap every four years: 3, 7, 11, 15, ... etc -# 100 (Romme's rule): leap every 4th and 400th year, but not 100th: 20, 24, ... 96, 104, ... 396, 400, ... -# 128 (von Mädler's rule): leap every 4th but not 128th: 20, 24, ... 124, 132, ... -# equinox [default]: use calculation of the equinox to determine date, never returns a leap year - def leap(year, method=None): ''' Determine if this is a leap year in the FR calendar using one of three methods: 4, 100, 128 (every 4th years, every 4th or 400th but not 100th, every 4th but not 128th) - ''' + Methods: + * 4 (concordance rule): leap every four years: 3, 7, 11, 15, ... etc + * 100 (Romme's rule): leap every 4th and 400th year, but not 100th: + 20, 24, ... 96, 104, ... 396, 400, 404 ... + * 128 (von Mädler's rule): leap every 4th but not 128th: 20, 24, ... 124, 132, ... + * equinox [default]: use calculation of the equinox to determine date, never returns a leap year + ''' method = method or 'equinox' if year in (3, 7, 11): return True - elif year < 15: + + if year < 15: return False if method in (4, 'continuous') or (year <= 16 and method in (128, 'madler', 4, 'continuous')): return year % 4 == 3 - elif method in (100, 'romme'): + if method in (100, 'romme'): return (year % 4 == 0 and year % 100 != 0) or year % 400 == 0 - elif method in (128, 'madler'): + if method in (128, 'madler'): return year % 4 == 0 and year % 128 != 0 - elif method == 'equinox': + if method == 'equinox': # Is equinox on 366th day after (year, 1, 1) startjd = to_jd(year, 1, 1, method='equinox') if premier_da_la_annee(startjd + 367) - startjd == 366.0: @@ -78,16 +78,36 @@ return False +def _previous_fall_equinox(jd): + '''Return the julian day count of the previous fall equinox.''' + y, _, _ = gregorian.from_jd(jd) + eqx = Sun.get_equinox_solstice(y, "autumn").jde() + if eqx > jd: + eqx = Sun.get_equinox_solstice(y - 1, "autumn").jde() + + return eqx + + +def _next_fall_equinox(jd): + '''Return the julian day count of the previous fall equinox.''' + y, _, _ = gregorian.from_jd(jd) + eqx = Sun.get_equinox_solstice(y, "autumn").jde() + if eqx < jd: + eqx = Sun.get_equinox_solstice(y + 1, "autumn").jde() + + return eqx + + def premier_da_la_annee(jd): - '''Determine the year in the French revolutionary calendar in which a given Julian day falls. - Returns Julian day number containing fall equinox (first day of the FR year)''' - p = ephem.previous_fall_equinox(dublin.from_jd(jd)) - previous = trunc(dublin.to_jd(p) - 0.5) + 0.5 + ''' + Returns Julian day number containing fall equinox (first day of the FR year) + of the current FR year. + ''' + previous = trunc(_previous_fall_equinox(jd) - 0.5) + 0.5 if previous + 364 < jd: # test if current day is the equinox if the previous equinox was a long time ago - n = ephem.next_fall_equinox(dublin.from_jd(jd)) - nxt = trunc(dublin.to_jd(n) - 0.5) + 0.5 + nxt = trunc(_next_fall_equinox(jd) - 0.5) + 0.5 if nxt <= jd: return nxt @@ -111,8 +131,7 @@ if method == 'equinox': return _to_jd_equinox(year, month, day) - else: - return _to_jd_schematic(year, month, day, method) + return _to_jd_schematic(year, month, day, method) def _to_jd_schematic(year, month, day, method): @@ -182,9 +201,10 @@ def _to_jd_equinox(an, mois, jour): + '''Return jd of this FR date, counting from the previous equinox.''' day_of_adr = (30 * (mois - 1)) + (jour - 1) - equinoxe = ephem.next_fall_equinox(str(an + YEAR_EPOCH)) - return trunc(dublin.to_jd(equinoxe.real) - 0.5) + 0.5 + day_of_adr + equinoxe = _next_fall_equinox(gregorian.to_jd(an + YEAR_EPOCH, 1, 1)) + return trunc(equinoxe - 0.5) + 0.5 + day_of_adr def from_jd(jd, method=None): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/gregorian.py new/convertdate-2.2.0/convertdate/gregorian.py --- old/convertdate-2.1.3/convertdate/gregorian.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/gregorian.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/hebrew.py new/convertdate-2.2.0/convertdate/hebrew.py --- old/convertdate-2.1.3/convertdate/hebrew.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/hebrew.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/holidays.py new/convertdate-2.2.0/convertdate/holidays.py --- old/convertdate-2.1.3/convertdate/holidays.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/holidays.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/indian_civil.py new/convertdate-2.2.0/convertdate/indian_civil.py --- old/convertdate-2.1.3/convertdate/indian_civil.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/indian_civil.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/islamic.py new/convertdate-2.2.0/convertdate/islamic.py --- old/convertdate-2.1.3/convertdate/islamic.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/islamic.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/iso.py new/convertdate-2.2.0/convertdate/iso.py --- old/convertdate-2.1.3/convertdate/iso.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/iso.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/julian.py new/convertdate-2.2.0/convertdate/julian.py --- old/convertdate-2.1.3/convertdate/julian.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/julian.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/julianday.py new/convertdate-2.2.0/convertdate/julianday.py --- old/convertdate-2.1.3/convertdate/julianday.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/julianday.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/mayan.py new/convertdate-2.2.0/convertdate/mayan.py --- old/convertdate-2.1.3/convertdate/mayan.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/mayan.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/ordinal.py new/convertdate-2.2.0/convertdate/ordinal.py --- old/convertdate-2.1.3/convertdate/ordinal.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/ordinal.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/persian.py new/convertdate-2.2.0/convertdate/persian.py --- old/convertdate-2.1.3/convertdate/persian.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/persian.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/positivist.py new/convertdate-2.2.0/convertdate/positivist.py --- old/convertdate-2.1.3/convertdate/positivist.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/positivist.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/convertdate/utils.py new/convertdate-2.2.0/convertdate/utils.py --- old/convertdate-2.1.3/convertdate/utils.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/convertdate/utils.py 2019-10-26 19:46:45.000000000 +0200 @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # This file is part of convertdate. @@ -24,7 +23,7 @@ def amod(a, b): '''Modulus function which returns numerator if modulus is zero''' modded = int(a % b) - return b if modded is 0 else modded + return b if modded == 0 else modded # Sane people of the world, use calendar.weekday! @@ -95,10 +94,10 @@ Return (year, month, day) tuple that represents nth weekday of month in year. If n==0, returns last weekday of month. Weekdays: Monday=0 """ - if not (0 <= n <= 5): + if not 0 <= n <= 5: raise IndexError("Nth day of month must be 0-5. Received: {}".format(n)) - if not (0 <= weekday <= 6): + if not 0 <= weekday <= 6: raise IndexError("Weekday must be 0-6") firstday, daysinmonth = calendar.monthrange(year, month) @@ -108,7 +107,7 @@ if n == 0: # find last weekday of kind, which is 5 if these conditions are met, else 4 - if first_weekday_of_kind in [1, 2, 3] and first_weekday_of_kind + 28 < daysinmonth: + if first_weekday_of_kind in [1, 2, 3] and first_weekday_of_kind + 28 <= daysinmonth: n = 5 else: n = 4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/setup.py new/convertdate-2.2.0/setup.py --- old/convertdate-2.1.3/setup.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/setup.py 2019-10-26 19:46:45.000000000 +0200 @@ -10,7 +10,7 @@ from setuptools import setup try: - readme = open('README.rst').read() + readme = open('README.md').read() except IOError: readme = '' @@ -27,6 +27,7 @@ "Indian Civil, Islamic, ISO, Julian, Mayan and Persian."), long_description=readme, + long_description_content_type='text/markdown', author="Neil Freeman", @@ -53,6 +54,8 @@ 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Topic :: Religion', 'Topic :: Scientific/Engineering :: Astronomy', 'Operating System :: OS Independent', @@ -60,7 +63,7 @@ ], install_requires=[ - 'ephem>=3.7.5.3, <3.8', - 'pytz>=2014.10, < 2020' + 'pytz>=2014.10, < 2020', + 'pymeeus>=0.3.6, <=1' ] ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/tests/test_bahai.py new/convertdate-2.2.0/tests/test_bahai.py --- old/convertdate-2.1.3/tests/test_bahai.py 1970-01-01 01:00:00.000000000 +0100 +++ new/convertdate-2.2.0/tests/test_bahai.py 2019-10-26 19:46:45.000000000 +0200 @@ -0,0 +1,78 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals +import unittest +import time +from convertdate import bahai + + +class TestBahai(unittest.TestCase): + + pairs = { + (2041, 11, 27): (198, 14, 6), # ascension of Abdu'l-Bahá 2041 + (2043, 11, 28): (200, 14, 6), # ascension of Abdu'l-Bahá 2043 + (2038, 3, 1): (194, 20, 1), # beginning of fast 2038 + (2039, 3, 2): (195, 20, 1), # beginning of fast 2039 + (2040, 3, 1): (196, 20, 1), # beginning of fast 2040 + (2041, 3, 1): (197, 20, 1), # beginning of fast 2041 + (2042, 3, 1): (198, 20, 1), # beginning of fast 2042 + (2043, 3, 2): (199, 20, 1), # beginning of fast 2043 + (2031, 10, 17): (188, 12, 2), # twin holy days, 2031 + (2031, 10, 18): (188, 12, 3) + } + + def setUp(self): + self.tm = time.localtime() + self.gregoriandate = (self.tm[0], self.tm[1], self.tm[2]) + + def test_gregorian_nawruz(self): + nawruz_official = { + 20: [ + 2016, 2017, 2020, 2021, 2024, 2025, 2028, 2029, 2030, 2032, + 2033, 2034, 2036, 2037, 2038, 2040, 2041, 2042, 2044, 2045, + 2046, 2048, 2049, 2050, 2052, 2053, 2054, 2056, 2057, 2058, + 2059, 2060, 2061, 2062, 2063, 2064 + ], + 21: [ + 2015, 2018, 2019, 2022, 2023, 2026, 2027, 2031, 2035, 2039, + 2043, 2047, 2051, 2055 + ] + } + + for date, gyears in nawruz_official.items(): + for gyear in gyears: + self.assertEqual((3, date), bahai.gregorian_nawruz(gyear)) + + def test_reflexive(self): + for jd in range(2159677, 2488395, 1867): + self.assertEqual(jd+0.5, bahai.to_jd(*bahai.from_jd(jd+0.5))) + + def test_to_gregorian(self): + for g, b in self.pairs.items(): + self.assertEqual(g, bahai.to_gregorian(*b)) + + def test_from_gregorian(self): + for g, b in self.pairs.items(): + self.assertEqual(b, bahai.from_gregorian(*g)) + + def test_month_length(self): + for x in range(1, 19): + self.assertEqual(bahai.month_length(2019, x), 19) + + def test_month_length_ha(self): + official = { + 4: [ + 2016, 2017, 2019, 2020, 2021, 2023, 2024, 2025, 2027, 2028, 2029, 2030, 2032, + 2033, 2034, 2036, 2037, 2038, 2040, 2041, 2042, 2044, 2045, 2046, 2048, 2049, + 2050, 2052, 2053, 2054, 2056, 2057, 2058, 2059, 2061, 2062, 2063, 2065 + ], + 5: [2018, 2022, 2026, 2031, 2035, 2039, 2043, 2047, 2051, 2055, 2060, 2064] + } + + for length, gyears in official.items(): + for gyear in gyears: + byear = gyear - 1844 + self.assertEqual(length, bahai.month_length(byear, 19)) + + +if __name__ == '__main__': + unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/tests/test_french_republican.py new/convertdate-2.2.0/tests/test_french_republican.py --- old/convertdate-2.1.3/tests/test_french_republican.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/tests/test_french_republican.py 2019-10-26 19:46:45.000000000 +0200 @@ -290,6 +290,13 @@ # Coup of 30 Prairial VII self.assertEqual(fr.to_gregorian(7, 9, 30), (1799, 6, 18)) + def test_premier_da_la_annee(self): + # Autumnal equinoxes in 1793 and 1794 + e0 = 2376204.5 + e1 = 2376569.5 + self.assertEqual(fr.premier_da_la_annee(e1 - 10), e0) + self.assertEqual(fr.premier_da_la_annee(e1 + 100), e1) + def test_french_republican_months(self): self.assertEqual(fr.MOIS[0], "Vendémiaire") self.assertEqual(fr.MOIS[1], "Brumaire") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/tests/tests.py new/convertdate-2.2.0/tests/tests.py --- old/convertdate-2.1.3/tests/tests.py 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/tests/tests.py 2019-10-26 19:46:45.000000000 +0200 @@ -110,12 +110,8 @@ def test_bahai(self): self.reflexive(bahai.from_jd, bahai.to_jd) - self.assertEqual(bahai.from_gregorian(1844, 3, 21), (1, 1, 1)) - self.assertEqual(bahai.to_gregorian(1, 1, 1), (1844, 3, 21)) self.assertEqual(bahai.month_length(1, 3), 19) self.assertEqual(bahai.month_length(1, 1), 19) - self.assertEqual(bahai.month_length(4, 19), 5) - self.assertEqual(bahai.month_length(5, 19), 4) self.assertEqual(self.jd, bahai.to_jd(*bahai.from_jd(self.jd))) def test_coptic(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/convertdate-2.1.3/tox.ini new/convertdate-2.2.0/tox.ini --- old/convertdate-2.1.3/tox.ini 2018-08-25 21:41:13.000000000 +0200 +++ new/convertdate-2.2.0/tox.ini 2019-10-26 19:46:45.000000000 +0200 @@ -1,12 +1,12 @@ # This file is part of convertdate. # http://github.com/fitnr/convertdate -# Licensed under the GPL-v3.0 license: +# Licensed under the MIT license: # http://opensource.org/licenses/MIT # Copyright (c) 2016, fitnr <fitnr@fakeisthenewreal> [tox] -envlist = py27,pypy,py34,py35,py36,pep8 +envlist = py27, pypy, py34, py35, py36, py37, py38, pep8 [testenv] deps = coverage
