Gossamer Forum
Quote Reply
Add_Date Global ?
Hi,

I'm hoping someone has done this or can help out

I need a global that would use Add_date and add 30 days to it giving me a date...I hope it sounds clear

example: a link was added April 1, 2007...when you add 30 days...the link would display May 1, 2007

all help is appreciated

Thanks
Quote Reply
Re: [incik] Add_Date Global ? In reply to
Hi,

Something like this?

<%global_name($Add_Date)%>

Code:
sub {
use GT::Date;
my $date = $_[0];
my $datenew = GT::Date::date_add($date1, 30);
return $date_new;
}

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] Add_Date Global ? In reply to
Hi Andy,

just tested this and this was the results

I added the link 4-9-2007 and
the result from the global gave me 1970-01-30

any ideas ?

Thanks
Quote Reply
Re: [incik] Add_Date Global ? In reply to
Hi,

This should work

sub {
use GT::Date;
my $date = $_[0];
my $datenew = GT::Date::date_add($date, 30);
return $date_new;
}
[/code]


Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [incik] Add_Date Global ? In reply to
Hi,

Quote:
just tested this and this was the results

I added the link 4-9-2007 and
the result from the global gave me 1970-01-30

Wow, I'm amazed it worked at all :D There were a couple of typos in it. Should have been $date (not $date1) and also $datenew, not $date_new Wink.

Anyway, Tadats global should do the job (same as mine, but without the typos :D)

Actually - Tadat made the same error as me on one line <G>

Code:
sub {
use GT::Date;
my $date = $_[0];
my $datenew = GT::Date::date_add($date, 30);
return $datenew;
}

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] Add_Date Global ? In reply to
Thanks guys

I had actually fixed the typos when I tried it and didnt mention it

but its still the same results and not working
Quote Reply
Re: [incik] Add_Date Global ? In reply to
Hi,

How are you calling the global from the template? That should work fine.

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] Add_Date Global ? In reply to
this is how I have it on the template

<%time($Add_Date)%>
Quote Reply
Re: [incik] Add_Date Global ? In reply to
Hi,

Mmm.. lets try some debugging.

Use this global:

Code:
sub {
print $IN->header();
use GT::Date;
my $date = $_[0];
print qq|Date passed in: $date <br />|;
my $datenew = GT::Date::date_add($date, 30);
print qq|New Date: $datenew <br />|;
return $datenew;
}

..then call the page, and see what it gives now?

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] Add_Date Global ? In reply to
that was neat

the results were:

Date passed in: 04-09-2007
New Date: 1970-01-30
Quote Reply
Re: [incik] Add_Date Global ? In reply to
Hi,

Ok, here's your problem :)

You need to convert the order of your date.

Add_Date has a date setting of mm-dd-yyyy, but GT::Date is using yyyy-mm-dd (standard format really).

Try this global;

Code:
sub {
print $IN->header();
use GT::Date;
my $date = $_[0];
$date =~ s|(\d+?)\-(\d+?)\-(\d+?)|$3-$1-$2|;
print qq|Date passed in: $date <br />|;
my $datenew = GT::Date::date_add($date, 30);
print qq|New Date: $datenew <br />|;
return $datenew;
}

Let me know how it goes :)

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!

Last edited by:

Andy: Apr 10, 2007, 9:31 AM
Quote Reply
Re: [Andy] Add_Date Global ? In reply to
I understand but not sure of how to fix it

heres the results:

Date passed in: 2-04-09007
New Date: 1970-01-30
Quote Reply
Re: [incik] Add_Date Global ? In reply to
Hi,

Ooops - guess something was wrong with my Regex above :D

Lets try the date_transform() function from GT::Date;

Code:
sub {
print $IN->header();
use GT::Date;
my $date = $_[0];
$date = GT::Date::date_transform ($date, "%mm%-%dd%-%yyyy%", "%yyyy%-%mm%-%dd%");
print qq|Date passed in: $date <br />|;
my $datenew = GT::Date::date_add($date, 30);
print qq|New Date: $datenew <br />|;
return $datenew;
}

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!

Last edited by:

Andy: Apr 10, 2007, 10:07 AM
Quote Reply
Re: [Andy] Add_Date Global ? In reply to
it gave me an error message


A fatal error has occured:
Links (586, GT::AutoLoader): Unknown method 'date_transform' called at (eval 41) line 5.

Quote Reply
Re: [incik] Add_Date Global ? In reply to
Hi,

Mmm.. odd. Try this instead:

$date = GT::Date::date_transform ($date, "%mm%-%dd%-%yyyy%", "%yyyy%-%mm%-%dd%");

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!