Issue 677764
Created on 2003-01-30 21:19 by anonymous, last changed 2003-03-19 05:30 by richard.
File name |
Uploaded |
Description |
Edit |
Remove |
date.py.diff
|
anonymous,
2003-01-30 21:19
|
Date.py Diff |
|
|
msg615 |
Author: [hidden] (anonymous) |
Date: 2003-01-30 21:19 |
|
I've made a few changes for our needs to the date.py
Date() and Interval()
classes, and thought I'd pass them along.
Motivations:
The ISO yyyy-mm-dd format was causing slight trouble,
and most of the users who
had trouble with it would enter dates like "1/23"
or "1/23/2003".
Also, I wanted to use Intervals for duedates on a tracker
instance I'm
creating, but users still wanted to be able to enter dates,
and have them
converted to Intervals automatically.
Changes:
I decided a compromise on the date formatting issue
was best, not to try to
fully change roundup's date format (as we all know the
ambiguities with the
m/d/year format). Instead, I simply made "/" an
alternative separator to "-",
so that "1/23" is properly converted. This handles most
of our needs, the rest
is met through education ("2003/1/23" for instance, or
the real ISO).
On the Interval side, I also went for a minimal change.
An additional term in
the spec regex is a trailing date spec. If it exists, it tries
to create a
date, adds that date to itself (an Interval), and subtracts
the result from now.
This allows Interval("+2d 1/23") (result: <Interval -4d> as
of 1/29), or most
important in our case, Interval("2/28") (result: <Interval
+29d> as of 1/29).
(A side note: an infinite loop is possible if there are
trailing bad chars, as
both classes now assume that trailing spec chars are a
possible spec for the
other class. Interval now has a default
argument "allowdate" to control this
behavior.)
Diff is below. Use it if you want.
- Luke Opperman
|
msg616 |
Author: [hidden] (richard) |
Date: 2003-03-19 05:30 |
|
Logged In: YES
user_id=6405
The first part of the patch is applied.
The second part of the patch is a problem though when the
"now" calculation happens over a day boundary. I've modified
the patch to at least handle time values a little better.
The day boundary problem is extraordinarily unlikely, but
would be messy ;)
ps. in the future, please supply context diffs (diff -c) so
I know which parts of the code you're adding your code to :)
pps. this ain't a bug, really ;)
|
|
Date |
User |
Action |
Args |
2003-01-30 21:19:20 | anonymous | create | |
|