Open GoogleCodeExporter opened 9 years ago
Sorry i dont know how to make it feature reuquets, not defect.
Original comment by bege...@gmail.com
on 27 Feb 2013 at 12:08
No biggie, I changed it to an 'Enhancement'.
One of the issues with datetime formats is establishing which datetime format
is being used. The loosely defined nature of the CSV format makes it
difficult/impossible to ensure that the datetime format implemented can match
all the different variations possible. In short, supporting date formats in a
'standard' way is a nightmare.
With that said, that doesn't mean they can't be supported at all. If you come
up with a specific date format you'd like to use then you can create a regex
match to check the input and auto-cast it to the right format.
To an extent, auto-casting is already implemented via the
$.csv.hooks.castToScalar() method. It's implemented by checking each parsed
value to see if it's a float, then int, and finally returns it as a string if
it doesn't match.
To implement what you're saying, the same method could be extended to check for
date types in a similar manner.
As another alternative, if you know that the date column is always the same,
you could skip the type detection and write a hook that always casts that
specific column's values to the datetime format.
I wouldn't add this to the 'core' parser because, by default, the parser
doesn't actually cast anything; partly to prevent any unexpected side-effects
(ie where casting isn't wanted) and partly for speed.
What you're suggesting is completely possible but will most likely be
implementation-specific. If you would like to take a shot at defining a
user-defined-callback, I can help point you in the right direction. BTW, the
hook you want to set is the onParseValue. Take a look at the 'Hooks' page in
the wiki for more info.
Original comment by evanpla...@gmail.com
on 27 Feb 2013 at 10:17
Thanks for fast reply!
I used your example
http://jquery-csv.googlecode.com/git/examples/google-visualization.html and
there is already onParseValue: $.csv.hooks.castToScalar, can i add another
line onParseValue: datetimeParse?
and there should be function that uses google api? like:
var datetimeParse = function(value, state) {
if(state.colNum = 0) { // My datetime field always go first
SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd");
return timeFormat.format(myDate);
}
return false;
}
Original comment by bege...@gmail.com
on 1 Mar 2013 at 9:34
Nice job.
Quick question. Where does the SimpleDateFormat class come from? If possible,
I'd prefer that the version that makes it into the codebase be dependency free.
Original comment by evanpla...@gmail.com
on 1 Mar 2013 at 5:52
Well, that my noobiness copied this beautifull piece of code somwhere in the
internet :) So i thought its sort of built into JS...
Original comment by bege...@gmail.com
on 2 Mar 2013 at 8:50
This'll be a nice addition to the documentation.
BTW, I've been messing with DateTime stuff on another project and it is -- in
fact -- a part of the JavaScript core. Also, it's a PITA to use.
Original comment by evanpla...@gmail.com
on 9 Dec 2013 at 11:31
Original issue reported on code.google.com by
bege...@gmail.com
on 27 Feb 2013 at 12:07