Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

How to pass a short date ?

Quote Reply
How to pass a short date ?
Hi all,
how can i pass Mod_Date in a shorter format e.g. as sMod_Date?

Robert
Quote Reply
Re: [Robert] How to pass a short date ? In reply to
Use this global code:
Code:
sub {
# Convert Mod_Date to sMod_Date.
my $tags = shift;
Links::init_date(); # do we need that?
my $Mod_Date_format = $CFG->{"date_user_format"};
my $sMod_Date_format = "%yyyy% %mm% %dd%";
my $sMod_Date = date_transform ($tags->{Mod_Date}, $Mod_Date_format, $sMod_Date_format );
return $sMod_Date;
}
Now you should use <%sMod_Date%> in links.html
I did not check if works (just written here Cool), but basically should work.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] How to pass a short date ? In reply to
Quote:
Links::init_date(); # do we need that?


Yes, as that guarantees that GT::Date is loaded. It doesn't matter if you call it multiple times as it returns right away if the date module is already loaded.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] How to pass a short date ? In reply to
I did not use the Date module since a long time, and I did not remember, if we really need to use.

Thanks for the info!

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] How to pass a short date ? In reply to
Thank you.
Quote Reply
Re: [Robert] How to pass a short date ? In reply to
Undefined subroutine &Links::date_transform called at (eval 40) line 7.


Seems there is an error in this global ?!

Robert
Quote Reply
Re: [Robert] How to pass a short date ? In reply to
It is strange.
Try to insert the following:
Code:
use Links qw/$IN $CFG/;
# before this:
Links::init_date();
Not sure if this will work.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...

Last edited by:

webmaster33: May 12, 2002, 5:59 AM
Quote Reply
Re: [webmaster33] How to pass a short date ? In reply to
sub {
# Convert Add_Date to sAdd_Date.
my $tags = shift;
Links::init_date();# do we need that?
my $Add_Date_format = $CFG->{"date_user_format"};
my $sAdd_Date_format = "%yyyy% %mm% %dd%";
my $sAdd_Date = GT::Date::format_date($tags->{Add_Date}, $Add_Date_format, $sAdd_Date_format);
return $sAdd_Date;
}

This is better, but not right:
Can't use string ("Mittwoch, 17.04.2002") as an ARRAY ref while "strict refs" in use at ...

Robert

BTW: There is an error in docu: I read format_date but in example, there is date_format ...

Last edited by:

Robert: May 12, 2002, 6:05 AM
Quote Reply
Re: [Robert] How to pass a short date ? In reply to
Ok, here we go:

sub {
# Convert Add_Date to sAdd_Date.
my $tags = shift;
Links::init_date();# do we need that?
my $date = $tags->{Add_Date};
my $orig_fmt = $CFG->{"date_user_format"};
my $new_fmt = "%dd%. %mm% %yyyy%";
my $sAdd_Date = GT::Date::date_transform($date, $orig_fmt, $new_fmt);
return $sAdd_Date;
}

Robert
Quote Reply
Re: [Robert] How to pass a short date ? In reply to
As I remember, GT::Date::date_transform is the correct syntax.
But I did not check Date.pm source now, check it yourself.
Yes, there is a bug in the docs & examples of Date.pm.
What LSQL version do you use? I use v2.1.0.

Seems you have bad input date or bad input format: Mittwoch, 17.04.2002.
Correct the input format string, to match your input date.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] How to pass a short date ? In reply to
Seems our postings have crossed; the last one is ok for me.
BTW: It would be a fine thing to have a new link next to every global to test it;
while i have to build now every time when change a global i have to wait a minute ;-(
still the build has finished.

Some ideas how to do that ?!
Robert
Quote Reply
Re: [Robert] How to pass a short date ? In reply to
sub {
# Convert Add_Date to sAdd_Date.
my $tags = shift;
Links::init_date();# do we need that?
my $date = $tags->{Add_Date};
my $orig_fmt = $CFG->{"date_user_format"};
my $new_fmt = "%dd%. %mm% %yyyy%";
my $sAdd_Date = GT::Date::date_transform($date, $orig_fmt, $new_fmt);
print "date: $date<br>\n";
print "orig_fmt: $orig_fmt <br>\n";
print "new_fmt: $new_fmt <br>\n";
print "sAdd_Date: $sAdd_Date<br>\n";
return $sAdd_Date;
}

I'm not sure this is what you want.
Oh BTW, you can use the dynamic displaying so you don't need to rebuild it...
Just ideas what you could do, because I don't really understand what kind of links would you want...

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] How to pass a short date ? In reply to
The last code i have posted does close that what i want:

Define a new Tag called sAdd_Date as a global.
It takes the normal Add_Date and pass it in the new format Day(2) Month(2) Year(2002)

;-)

Robert