douglashowe / as3flickrlib

Automatically exported from code.google.com/p/as3flickrlib
0 stars 0 forks source link

invalid date format in the Photos search method #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In Photos.as:

In function  search() when it invokes MethodGroupHelper, the min_taken_date
and max_taken_date parameters should be in mysql datetime format, not
milliseconds as stated in the Flickr API docs. I had to tweak them to make
this work. 

A sample fix might look something like this:
=======================================================

var new_min_taken_date:String;
var new_max_taken_date:String;

if( min_taken_date != null )
{
    var _date:String  = min_taken_date.date.toString();
    var _month:String = String( min_taken_date.month + 1 );
    var _year:String  = min_taken_date.fullYear.toString();

    _date =  ( _date.length == 1 )  ? "0" + _date  : _date;
    _month = ( _month.length == 1 ) ? "0" + _month : _date;

    new_min_taken_date = _year + "-" + _month + "-" + _date + "
00:00:00";
}
if( max_taken_date != null )
{
    var _date:String  = max_taken_date.date.toString();
    var _month:String = String( max_taken_date.month + 1 );
    var _year:String  = max_taken_date.fullYear.toString();

    _date =  ( _date.length == 1 )  ? "0" + _date  : _date;
    _month = ( _month.length == 1 ) ? "0" + _month : _date;

    new_max_taken_date = _year + "-" + _month + "-" + _date + "
00:00:00";
}

And then replace the 2 lines in the invokeMethod call...

new NameValuePair( "min_taken_date", min_taken_date == null ? "" :
new_min_taken_date ),
new NameValuePair( "max_taken_date", max_taken_date == null ? "" :
new_max_taken_date ),

Original issue reported on code.google.com by darron.schall on 13 Dec 2006 at 9:36

GoogleCodeExporter commented 8 years ago
At some stage, the Flickr API documentation was updated and confirms that these 
dates
should be in MySQL DATETIME format.

Darren: Let me know if you're still intending to check in a fix for this issue. 
I'm
going through the as3flickrlib trying to clear up outstanding issues and any API
incompatibilities, and am happy to pick this up if you're too busy.

Original comment by spjwebster@gmail.com on 2 Feb 2008 at 9:57

GoogleCodeExporter commented 8 years ago
I ran into this issue and fixed it myself before seeing this!

I'm not sure if DateFormatter's were in Flex back in 2006, but I did the 
following

In the constructor I did this:
dateFmt = new DateFormatter();
dateFmt.formatString = "YYYY-MM-DD 00:00:00";       

Then, when it comes time to pass in the min and max dates, I did the following
dateFmt.format(min_taken_date)

I don't have access to the respository but if anyone does and sees this they 
can 
post it if they like!
dateFmt.format(max_taken_date)

Original comment by khuffie on 26 Feb 2008 at 8:37