Hi Jeremy, Excellent, it works:
generateRelativePubDate(entry.publishedDate, "ymd"); Thanks, Sebastian On 22/04/09 14:23, "Jeremy Geerdes" <[email protected]> wrote: > 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){ > if(typeof(theDate)=='string'){theDate=new Date(theDate)} > var now = (new Date).getTime(), > then = theDate.getTime(); > if(now<then){return (2).toString()+strings['minutes_ago']} > var difference=now-then; > 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&&format.match(/^ymd$/i)){return > [theDate > .getFullYear(),mos[theDate.getMonth()],theDate.getDate()].join(' ')} > else if(format&&format.match(/^dmy$/i)){return > [theDate > .getDate(),mos[theDate.getMonth()],theDate.getFullYear()].join(' ')} > else{return [mos[theDate.getMonth()],theDate.getDate() > +',',theDate.getFullYear()].join(' ')} > } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
