commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C. Scott Ananian" <csc...@cscott.net>
Subject Re: [lang] DateUtils.parseCVS
Date Wed, 07 Jul 2004 17:51:10 GMT
On Wed, 7 Jul 2004, Serge Knystautas wrote:

> Steven Caswell wrote:
> > That does make things a little clearer. Perhaps it should be it's own
> > class, with a parse and a format method, a la SimpleDateFormat.
>
> I'm unclear how the format part would work.  "yesterday", "1 day ago",
> and "24 hours ago" all parse to the same Date object, so I don't know
> how to provide formatting preferences.  AFAIK CVS does not support
> compound "ago"s, so while nice, it would be harder to do "1 day and 2
> hours ago".

I wrote something like this for svn/apache apr at one point; the best
solution seemed to be to use plain language format strings that would be
matched in turn against the selected text.  Something like "%d %u ago"
where %d matches a number and %u matches a unit.  You have to be careful
because a day is not always 60*60*24 seconds long.

The formatter wouldn't necessarily generate *all* of the strings the
parser could recognize, but a "user-friendly time" formatter that would
give human-friendly time specifications like "yesterday at 4pm" would
certainly be nice.  You could also use a "loose" formatter which would say
things like "less than 5 minutes ago" or "about an hour ago".  All the
things emitted by the strict formatter should be recognized by the parser;
it may or may not be useful for the parser to recognize things emitted by
the loose formatter.
 --scott

chemical agent Sigint Japan Indonesia cracking Iraq Nazi Dictionary
SSBN 743 assassination politics biowarfare Israel corporate globalization
                         ( http://cscott.net/ )

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message