: Digging into the source code of DateMathParser.java, i found the following 
: comment:
:    99       // NOTE: consciously choosing not to support WEEK at this time,   
: 100       // because of complexity in rounding down to the nearest week   101 
      
: // arround a month/year boundry.   102       // (Not to mention: it's not 
clear 
: what people would *expect*) 
: 
: I was able to implement a work-around in my ruby client using the following 
: pseudo code:
:   wd=NOW.wday; "NOW-#{wd}DAY/DAY"

the main issue that comment in DateMathParser.java is refering to is what 
the ambiguity of what should happen when you try do something like 
"2009-01-02T00:00:00Z/WEEK"

"WEEK" would be the only unit where rounding changed a unit 
*larger* then the one you rounded on -- ie: rounding day only affects 
hours, minutes, seconds, millis; rounding on month only affects days, 
hours, minutes, seconds, millies; but in an example like the one above, 
where Jan 2 2009 was a friday.  rounding down a week (using logic similar 
to what you have) would result in "2008-12-28T00:00:00Z" -- changing the 
month and year.

It's not really clear that that is what people would expect -- i'm 
guessing at least a few people would expect it to stop at the 1st of the 
month.

the ambiguity of what behavior makes the most sense is why never got 
arround to implementing it -- it's certianly possible, but the 
various options seemed too confusing to really be very generally useful 
and easy to understand 

as you point out: people who really want special logic like this (and know 
how they want it to behave) have an easy workarround by evaluating "NOW" 
in the client since every week has exactly seven days.



-Hoss

Reply via email to