[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [GT] Q re DateTime and Date format too
Weigert, Thomas wrote:
Here is a tricky issue I discovered:
The current code in DateTime::Month is inconsistent with both the
documentation and the usage in DateTime::Day.
The documentation and DateTime::Day requires a format that separates the
time entities by "-": YYYY-MM-DD, YYYY-MM.
The code in DateTime::Month, however, implements "/" as separator:
YYYY/MM.
I believe the latter is a mistake. Please advise whether anybody relies
on this inconsistency. If I don't hear anything back, I shall fix this
to be consistent and use YYYY-MM as the format.
Cheers, Th.
In DB/Text.pm it is stated that any date format understood by
Date::Manip is supported. However, the routines in
GT::DateTime::Day::date_to_time and similar in the other DateTime
modules insist that the dates are stored in the YYYY-MM-DD format.
It appears that there was an attempt to support more flexible date
parsing via GT::Tools::parse_date_str but I cannot see any usage of
that.
Is the repository outdated with respect to date parsing, or is the
documentation incorrect and this has not been implemented yet?
What is the status of GT::Tools::parse_date_str?
Please advise, Th.
my understanding, and it may be fully (or just partially) in error,
is that date string formats vary depending on the timeframe.
timeframe date string
sub day YYYY-MM-DD HH:MM:SS
day YYYY-MM-DD (time optional)
week YYYY-ww where ww 01 to 53 (leading zero required iirc)
month YYYY/MM
year YYYY
i don't believe the YYYY/MM is a mistake, it seems to accept and
do correct things with that string. i believe the mistake is not
disambiguating YYYY-MM-DD from YYYY-ww and not emphasizing it
in the documentation.
in a week time frame YYYY-MM-DD is accepted, but is used incorrectly,
as MM isn't the same as ww. try a weekly graphic.pl with start
at 2007-06-01 and end at 2007-12-04 -- notice how the graph starts
on the 6th week of 2007 and ends on the 12th week.
( svn_repo/graphic.pl --timeframe=week --start=2007-06-01 --end 2007-12-31 \
--type=candle -volume --volume-height=150 --logarithmic T > graphs/Ttest.png)
these date strings are typically entered on script command lines and
read from various configuration files. i don't know how or if this
affects reads from a database. but to change the internally used
formats are going to cause no end to trouble in my opinion.
that date strings vary is annoying, but the worst part, from a user
prospective is there appears to be no internal conversion between
formats to the corresponding timeframe. (at least my experience with
graphic.pl).
GT::Tools::parse_date_str was my attempt to provide a conversion utility
for scripts (and anything else that wants to check a date string and
convert it to correspond to a time frame). give it a variable containing
a date string and on a positive return the date string will correspond
with the current time frame, otherwise it returns zero and an error.
it does not require Date:Manip to operate, however, if that module is
available the input date string can be (almost) anything that looks like
a date (to a person at least).
there are probably no recorded users of it in the repository, my modified
scripts (graphic.pl, scan.pl, display_*.pl) all use it. haven't gotten
around to committing them (they are too customizedly broken for that).
it would be a good thing (for users) if script updates started to use it.
aloha
ras