7066: use sdn module from Calendar package on pypi

Unfortunately, no package on ubuntu for sdn...

Bug fixed on trunk, when sdn is present on the system.
Verified that sdn roundtrip works.
date_test now fails on 1789-13-4(French) recognized as invalid,
as it probably should -- I guess this one is a test bug.

svn: r23127
This commit is contained in:
Vassilii Khachaturov 2013-09-14 19:42:48 +00:00
parent 4d82a70eaa
commit a58b5cf2b7
2 changed files with 20 additions and 2 deletions

View File

@ -23,7 +23,7 @@
""" """
Provide calendar to sdn (serial date number) conversion. Provide calendar to sdn (serial date number) conversion.
""" """
from __future__ import division from __future__ import division, print_function
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Python modules # Python modules
@ -261,7 +261,7 @@ def hebrew_sdn(year, month, day):
return sdn + _HBR_SDN_OFFSET return sdn + _HBR_SDN_OFFSET
def hebrew_ymd(sdn): def hebrew_ymd(sdn):
"""Convert an SDN number to a Julian calendar date.""" """Convert an SDN number to a Hebrew calendar date."""
input_day = sdn - _HBR_SDN_OFFSET input_day = sdn - _HBR_SDN_OFFSET
@ -573,3 +573,14 @@ def swedish_ymd(sdn):
return gregorian_ymd(sdn) return gregorian_ymd(sdn)
else: else:
return julian_ymd(sdn) return julian_ymd(sdn)
try:
import sdn
hebrew_ymd = sdn.SdnToJewish # Fix bug# 7066
hebrew_sdn = sdn.JewishToSdn
#TODO maybe alias the other local invented wheels to Calendar convertors
except ImportError:
import sys
print("No sdn module. Install Calendar with pypi."
"hebrew_sdn has a known bug# 7066!!!", file=sys.stderr)

View File

@ -320,6 +320,12 @@ def show_settings():
except: except:
gsversion_str = 'Ghostscript not in system PATH' gsversion_str = 'Ghostscript not in system PATH'
try:
import sdn
sdn_str = sdn.__version__
except ImportError:
sdn_str = 'not found'
os_path = os.environ.get('PATH','not set') os_path = os.environ.get('PATH','not set')
os_path = os_path.split(os.pathsep) os_path = os_path.split(os.pathsep)
@ -342,6 +348,7 @@ def show_settings():
print (' GExiv2 : %s' % gexiv2_str) print (' GExiv2 : %s' % gexiv2_str)
print (' ICU : %s' % icu_str) print (' ICU : %s' % icu_str)
print (' PyICU : %s' % pyicu_str) print (' PyICU : %s' % pyicu_str)
print (' sdn : %s' % sdn_str)
print (' o.s. : %s' % sys.platform) print (' o.s. : %s' % sys.platform)
if kernel: if kernel:
print (' kernel : %s' % kernel) print (' kernel : %s' % kernel)