The relative published date that you see in the feed control is  
generated in the Javascript portion of the API using an obfuscated  
function which is essentially the same thing that I provided.  
Unfortunately, it's really not possible to access the code that's  
already built into the API for two reasons: ( 1 ) the compilation  
process that Google uses makes it impossible to guarantee that the  
function will be accessible by the same reference from update to  
update, and ( 2 ) the JS portion of the API is enclosed in an  
anonymous function which makes tracking it down and accessing it  
rather difficult.

So no, you really can't just call what they have without some  
significant and ongoing effort.

That said, a possible workaround would be to call the FeedControl's  
createHtml method, which uses the relativePublishedDate function  
internally.  Basically, you would instantiate a FeedControl and then  
call feedControl.createHtml(entry);, and the function will generate an  
html node including title, published date, relative published date,  
snippet, etc. - the same thing that is used in the regular FeedControl.

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
http://jgeerdes.blogspot.com
http://jgeerdes.wordpress.com
[email protected]

Unless otherwise noted, any price quotes contained within this  
communication are given in US dollars.

If you're in the Des Moines, IA, area, check out Debra Heights  
Wesleyan Church!

And check out my blog, Adventures in Web Development, at 
http://jgeerdes.blogspot.com 
  !


On Apr 22, 2009, at 2:13 AM, neonp wrote:

>
> Hello Jeremy,
>
> Does this mean, there is no way to reuse the function included in the
> Google feeds API, or to have a relative date on the feed entries
> directly ?
>
> Thanks, for your code, (looks like the one in the Google API I've
> read)
>
>
>
> On 21 avr, 22:35, Jeremy Geerdes <[email protected]> wrote:
>> The code for generating the relative published date is essentially  
>> this:
>>
>> var strings={
>>   "minutes_ago":' minutes ago',
>>   "one_hour_ago":'1 hour ago',
>>   "hours_ago":' hours ago'};
>>
>>   var mos=[
>>   'January',
>>   'February',
>>   'March',
>>   'April',
>>   'May',
>>   'June',
>>   'July',
>>   'August',
>>   'September',
>>   'October',
>>   'November',
>>   'December'
>> ];
>> function generateRelativePubDate(theDate,format){
>>   var now = (new Date).getTime(),
>>   then = theDate.getTime();
>>   if(now<then){return 2.toString()+strings['minutes_ago']}
>>   var difference=now-this;
>>   if(difference<3600000){
>>    var n=Math.floor(1/60000);
>>    return (n<=difference?2:n).toString()+strings['minutes_ago'];
>>   }
>>   if(difference<86400000){
>>    var n=Math.floor(1/3600000);
>>    if(n<=1){return strings['one_hour_ago']}
>>    else{return v.toString()+strings['hours_ago']}
>>   }
>>   if(format.match(/^ymd$/i)){return join(' ',
>> [theDate.getFullYear(),mos[theDate.getMonth()],theDate.getDate()])}
>>   else if(format.match(/^dmy$/i)){return join(' ',
>> [theDate.getDate(),mos[theDate.getMonth()],theDate.getFullYear()])}
>>   else{return join(' ',[mos[theDate.getMonth()],theDate.getDate()
>> +',',theDate.getFullYear()])}
>>
>> }
>>
>> The function takes two arguments. The first is a date object which  
>> can
>> be obtained by calling new Date(entry.publishedDate), and the second
>> is the format you want the date to appear in. By specifying a format
>> of "ymd," whenever it returns the actual date, it'll be in the form
>> yyyy mon dd. Similarly, by specifying a format of "dmy," any full  
>> date
>> string will be in the form dd mon yyyy.
>>
>> Also notice that I've separated out the key response strings, which
>> you may want to localize.
>>
>> Jeremy R. Geerdes
>> Effective website design & development
>> Des Moines, IA
>>
>> For more information or a project quote:http://jgeerdes.home.mchsi.comhttp 
>> ://jgeerdes.blogspot.comhttp://jgeerdes.wordpress.com
>> [email protected]
>>
>> Unless otherwise noted, any price quotes contained within this
>> communication are given in US dollars.
>>
>> If you're in the Des Moines, IA, area, check out Debra Heights
>> Wesleyan Church!
>>
>> And check out my blog, Adventures in Web Development, 
>> athttp://jgeerdes.blogspot.com
>>   !
>>
>> On Apr 21, 2009, at 10:21 AM, neonp wrote:
>>
>>
>>
>>
>>
>>> Hello,
>>
>>> I am retrieving rss feeds using new google.feed.Feed(url). However,
>>> retrieving feeds like this let me no option to get a relative
>>> published date. Is there any way to reuse the google's feed API
>>> without using a FeedControl ?
>>
>>> Thanks,
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to