From c202f43e9b8563db004d9ce14afcb6caa5e65926 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Thu, 22 Oct 2009 04:15:18 +0000 Subject: [PATCH] Fixed two errors: simple str(date) now shows alternate newyear day; match with alt newyear day now works correctly svn: r13390 --- src/gen/lib/date.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py index b5b173329..9956683ad 100644 --- a/src/gen/lib/date.py +++ b/src/gen/lib/date.py @@ -910,9 +910,10 @@ class Date(object): new_date.set_yr_mon_day(*dateval[:3]) return new_date.offset(offset) - datecopy = Date(self) + datecopy = Date(self) #we do all calculation in Gregorian calendar datecopy.convert_calendar(Date.CAL_GREGORIAN) + start = yr_mon_day(datecopy.get_start_date()) stop = yr_mon_day(datecopy.get_stop_date()) @@ -1028,11 +1029,28 @@ class Date(object): else: pref = "" - if self.calendar != Date.CAL_GREGORIAN: - cal = " (%s)" % Date.calendar_names[self.calendar] + if self.newyear == Date.NEWYEAR_JAN1: + ny = "" + elif self.newyear == Date.NEWYEAR_MAR1: + ny = "Mar1" + elif self.newyear == Date.NEWYEAR_MAR25: + ny = "Mar25" + elif self.newyear == Date.NEWYEAR_SEP1: + ny = "Sep1" else: - cal = "" + ny = "Err" + if self.calendar != Date.CAL_GREGORIAN: + if ny: + cal = " (%s,%s)" % (Date.calendar_names[self.calendar], ny) + else: + cal = " (%s)" % Date.calendar_names[self.calendar] + else: + if ny: + cal = " (%s)" % ny + else: + cal = "" + if self.modifier == Date.MOD_TEXTONLY: val = self.text elif self.get_slash(): @@ -1495,7 +1513,7 @@ class Date(object): """ Convert the date from the current calendar to the specified calendar. """ - if calendar == self.calendar: + if calendar == self.calendar and self.newyear == 0: return (year, month, day) = Date._calendar_change[calendar](self.sortval) if self.is_compound():