2008-02-23 Douglas S. Blank <dblank@cs.brynmawr.edu>
* src/gen/lib/date.py (Date.get_stop_date): added new method Date.to_calendar; dates return None if error svn: r10102
This commit is contained in:
parent
1fdfbedac3
commit
2180fa02cb
@ -1,3 +1,7 @@
|
|||||||
|
2008-02-23 Douglas S. Blank <dblank@cs.brynmawr.edu>
|
||||||
|
* src/gen/lib/date.py (Date.get_stop_date):
|
||||||
|
added new method Date.to_calendar; dates return None if error
|
||||||
|
|
||||||
2008-02-23 Jerome Rapinat <romjerome@yahoo.fr>
|
2008-02-23 Jerome Rapinat <romjerome@yahoo.fr>
|
||||||
* configure.in : allow Slovenian support
|
* configure.in : allow Slovenian support
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ class Date:
|
|||||||
diff += 1
|
diff += 1
|
||||||
eDate = eDate + (0, 0, diff)
|
eDate = eDate + (0, 0, diff)
|
||||||
if diff == 60:
|
if diff == 60:
|
||||||
return (0, 0, 0)
|
return None
|
||||||
return (years, months, days - diff)
|
return (years, months, days - diff)
|
||||||
elif eDate > date2:
|
elif eDate > date2:
|
||||||
diff = 0
|
diff = 0
|
||||||
@ -330,7 +330,7 @@ class Date:
|
|||||||
diff -= 1
|
diff -= 1
|
||||||
eDate = eDate - (0, 0, abs(diff))
|
eDate = eDate - (0, 0, abs(diff))
|
||||||
if diff == -60:
|
if diff == -60:
|
||||||
return (0, 0, 0)
|
return None
|
||||||
return (years, months, days + diff)
|
return (years, months, days + diff)
|
||||||
else:
|
else:
|
||||||
return (years, months, days)
|
return (years, months, days)
|
||||||
@ -1003,3 +1003,13 @@ class Date:
|
|||||||
else:
|
else:
|
||||||
raise AttributeError("invalid modifier: '%s'" % modifier)
|
raise AttributeError("invalid modifier: '%s'" % modifier)
|
||||||
|
|
||||||
|
def to_calendar(self, calendar_name):
|
||||||
|
"""
|
||||||
|
Return a new Date object in the calendar calendar_name.
|
||||||
|
>>> Date("Jan 1 1591").to_calendar("julian")
|
||||||
|
1590-12-22 (Julian)
|
||||||
|
"""
|
||||||
|
cal = self.lookup_calendar(calendar_name)
|
||||||
|
retval = Date(self)
|
||||||
|
retval.convert_calendar(cal)
|
||||||
|
return retval
|
||||||
|
Loading…
Reference in New Issue
Block a user