On Sat, 30 May 2009, Steven Schubiger wrote:
DateTime::Format::Natural currently does calculate its dates and times with an initial DateTime object received by "DateTime->now" (with timezone support). As a consequence thereof, many resulting final DateTime objects within DateTime::Format::Natural will retain for units that have not been altered the initial values.Clayton L. Scott suggested to introduce a "date_only" option, which would ignore (or reset) the time part for date-only strings. I intend to provide the names of the units to reset through according metadata entries in the grammar class. Later when post-processing data, the units would be resetted. Some examples from the adjusted and yet unreleased tests: * 27/5/1979 (without date_only: 27.05.1979 01:13:00) (with date_only: 27.05.1979 00:00:00) * yesterday (without date_only: 23.11.2006 01:13:08) (with date_only: 23.11.2006 00:00:00) * next hour (without date_only: 24.11.2006 02:13:08) (with date_only: 24.11.2006 02:00:00) * sunday 11:00 (without date_only: 26.11.2006 11:00:08) (with date_only: 26.11.2006 11:00:00) As mentioned above, I concur that it is worthwhile to implement (i.e., set the option per default and leave it open to the user to disable it), but I'm a bit unsure that "date_only" is the most suitable name for this new constructor option (given that it does not always reset just all time components). Suggestions and ideas welcome.
Actually, the current behavior just seems broken. I'd suggest that you should _always_ truncate to the most specific parsed value.
The current behavior is just confusing as heck in all the example up above.
-dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
