Differences between revisions 12 and 13
Revision 12 as of 2005-02-14 02:20:00
Size: 2824
Comment:
Revision 13 as of 2005-02-14 14:04:34
Size: 2922
Editor: 195
Comment:
Deletions are marked like this. Additions are marked like this.
Line 42: Line 42:


---

Might [http://joda-time.sourceforge.net/ Joda Time] come in handy?

- SimonBrunning

FrankWierzbicki is leading the implementation of the datetime module.

Background

Python 2.3 introduced a new module datetime.

Since this module is implemented in C, it would be nice to have a Java implementation for Jython. A pure Python implementation of datetime can be found at

I plan on using this implementation extensively as the Java version is developed. If it turns out that a Java implementation is infeasible or will take too long, we could always fall back on using this module directly.

My original plan was to write the entire module in Java, using zxDateTime for guidance

However, after reading this addition by BrianZimmer to JythonModulesInJava:

  My new approach is borrowed slightly from CPython where it's very
common to write a C library, a straight wrapper and then a Pythonic
wrapper. In Jython, the first two steps are really one so the
development effort is significantly simplified. Writing a wrapper in
Python offers the dual benefits of being easy to maintain and refactor
as well as requiring less development time.

And after discussing it with Brian, I've re-thought that approach, and I now plan to start with the pure python datetime and replace the date related code with [http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html java.util.Calendar] code.

Design

Python Class (from pure Python implementation)

Strategy

timexxx

I think this is just a placeholder for something in C...

timedelta

For now I plan to leave this alone, though this may be a place where a Java reimplementation may give a performance boost.

date

Replace most logic with java.util.Catalog code.

tzinfo

This is an abstract class, a wrapper so that [http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html java.util.TimeZone] could be used would be nice

time

Leave as is for now, but review later

datetime

Replace most logic with java.util.Catalog code.

Discussion

FrankWierzbicki 2005-02-13

For the short term I plan to use the Python unit tests as the absolute definition of the datetime module, and will not try to go beyond the CPython implementation. This means (for example) that dates will be limited to 1-9999AD, because that is what the CPython unit tests expect. Even though java.util.Calendar does not have this limitation, I will enforce it. This may change once Jython starts to catch up with the leading edge of CPython development and we can productively review the unit tests themselves.

---

Might [http://joda-time.sourceforge.net/ Joda Time] come in handy?

- SimonBrunning

DateTimeModule (last edited 2008-11-15 09:15:59 by localhost)