Gossamer Forum
Home : General : Perl Programming :

question about GT::Date::date_transform

Quote Reply
question about GT::Date::date_transform
Hi all,

Not sure if I should post this here or in the Discussion forum since it involves a GT module, but I trust it will be moved if necessary...

In any event, I'm having a heck of a time trying to transform some funky time strings using GT::Date::date_transform. The string formats are basically in 24 hour format without any colons or anything. Just a 3 or 4 digit string. For example, for 6:00 AM, the string would be '600'. For 10:30 PM, the string would be '2230'. Simple enough, right?

Well, here's what I'm using to transform it to a friendlier format:

Code:
GT::Date::date_transform($time,'%H%%MM%','%h%:%MM% %tt%')


Problem is, it doesn't return anything... Anyone have any idea where I'm going wrong??

Many thanks in advance.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] question about GT::Date::date_transform In reply to
Why not try something like this, if the times are all you need;

Code:
my ($hours,$mins);
if ($time =~ m/\d{2,2}\d{2,2}/) { $hours = $1; $mins = $2; }

Untested code, but the idea is there :)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: Jul 22, 2003, 3:06 PM
Quote Reply
Re: [Andy] question about GT::Date::date_transform In reply to
Thanks for the suggestion. I admit I'm not much of a perl coder at all, but don't we need to feed the original $time string into that regex somewhere??

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] question about GT::Date::date_transform In reply to
Whoops...edited above post.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] question about GT::Date::date_transform In reply to
Thanks - that does make a bit more sense. I'm afraid it still isn't working, though.

Here's what I've got:

Code:
my ($hour, $min);
if ($time =~ m/\d{2,2}\d{2,2}/) {
$hour = $1;
$min = $2;
}
I've tried it where $time is set to '800' and also where it's set to '1000' and in both cases $hour and $min were empty.

Any other ideas?

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] question about GT::Date::date_transform In reply to
Sorry, I'm working late. Try;

if ($time =~ m/(\d\d)(\d\d)/) {

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] question about GT::Date::date_transform In reply to
Thanks! We're making progress. Smile

This version works for '1000' but not for '800'. Could it be because '800' is only three characters long?

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] question about GT::Date::date_transform In reply to
Fixed it. Just had to change the regex to:

$time =~ m/(\d\d?)(\d\d)/

Thanks again for your help with this, Andy.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] question about GT::Date::date_transform In reply to
Glad to hear it Cool

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [hennagaijin] question about GT::Date::date_transform In reply to
You should use (?: as you aren't capturing any of the matches and so by letting the regex engine know you don't want to capture anything it will improve performance.
Quote Reply
Re: [Paul] question about GT::Date::date_transform In reply to
Thanks, Paul.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund