Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Format date for XML feed of new links

Quote Reply
Format date for XML feed of new links
Hi all

I've setup a Glinks new links XML feed using the PageBuilder plugin, (if you want to know any of the details let me know btw).

Everything is setup correctly except for the lastBuildDate and pubDate per item.

I'm using the last_build var for lastBuildDate and Date_Checked for pubDate, my server is in Canada so I'm attempting to convert those two dates to GMT (subtract 7 hours).

This is as far as I've got:

Code:
<%~ set serverTimeOffset = GT::Date::date_sub($Date_Checked, (60 * 60 * 7))%>
<pubDate><%serverTimeOffset%> GMT</pubDate>

Outputs the correct time for GMT:
<pubDate>2010-04-27 GMT</pubDate>

But when formatting it
Code:
<%~ set serverTimeOffset = GT::Date::date_sub($Date_Checked, (60 * 60 * 7))%>
<pubDate><%GT::Date::date_transform($serverTimeOffset, '%yyyy%-%mm%-%dd% %HH%:%MM%:00', '%ddd%, %dd% %mmm% %yyyy% %HH%:%MM%:00')%> GMT</pubDate>

Outputs:
<pubDate> GMT</pubDate>

And calling date_transform with Date_Checked on it's own does work, just without the time offset.
Code:
<pubDate><%GT::Date::date_transform($Date_Checked, '%yyyy%-%mm%-%dd% %HH%:%MM%:00', '%ddd%, %dd% %mmm% %yyyy% %HH%:%MM%:00')%> GMT</pubDate>

Outputs:
<pubDate>Tue, 27 Apr 2010 05:13:00 GMT</pubDate>

Something obvious I'm missing or an alternative way to do this?

In a few places in the forums I see people referring to the documentation for GT::Date (for example), where are these docs located? Don't seem to be part of the versions of Glinks/ LinksSQL I've ever downloaded.


Thanks

Charlie



Comedy Quotes - Glinks 3.3.0, PageBuilder, StaticURLtr, CAPTCHA, User_Edit_Profile

Quote Reply
Re: [Chas-a] Format date for XML feed of new links In reply to
Hi,

Date_Checked actually looks like:

2008-10-31 07:06:36

.. so not sure GT::Date::date_sub() is doing what you want (60*60*7 is actually the number of seconds in 7 hours)

GT::Date::date_sub is actually designed to work like so:

Code:
my $date1 = date_get();
my $date2 = date_sub($date1, 7);

(the above removes 7 DAYS - not hours)

I'm not really sure how GT::Date can do what you're trying to do (removing 7 hours)

For the docs, click on "Help" in gLinks admin - then goto GT Module Documentation, then find "Date" on the left side. All the docs are there Smile

One thing you could maybe try, is a decimal of a day (for example, 0.25 would be 6 hours). Can't see it working - but I guess its worth a try.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Format date for XML feed of new links In reply to
This seems to work.

Code:
<pubDate><%GT::Date::date_transform($Date_Checked, '%yyyy%-%mm%-%dd% %HH%:%MM%:00', '%ddd%, %dd% %mmm% %yyyy% %HH%:%MM%:00 %o%')%></pubDate>

Cheers Andy



Comedy Quotes - Glinks 3.3.0, PageBuilder, StaticURLtr, CAPTCHA, User_Edit_Profile