Mailing List Archive

[Bricolage-General] RE: date formatting
David,

I looked through Data.pm in /Bric/Biz/Asset/Business/Parts/Tile and saw the
added code for date formatting, but when I try to grab a formatted date
string like this:

if (my $pubdate = $element->get_data('publication_date', $format_string)) {
$formatted_date = local_date($pubdate, "%B %Y");
}

the get_data returns nothing, and doesn't return an error, as far as I can
tell. Any ideas about what i'm doing wrong?

Phil

-----Original Message-----
From: David Wheeler [mailto:david@wheeler.net]
Sent: Monday, September 23, 2002 9:06 AM
To: Philip Fibiger
Cc: bricolage-general@lists.sourceforge.net
Subject: Re: [Bricolage-General] date formatting


On Monday, September 23, 2002, at 08:24 AM, Philip Fibiger wrote:

> However, now get_data on a bric date field no longer returns an ansi
> date
> string, it returns a typically formatted date string: Month Day, Year.
> Is
> there any way to change what kind of date string is returned, or
> should I
> just parse the new date string and get what I want.

There are two ways. You can a) change the date formatting preference,
or b) pass in a strftime format string to get_data(). The date will be
returned in your local time zone.

HTH,

David

--
David Wheeler AIM: dwTheory
david@wheeler.net ICQ: 15726394
http://david.wheeler.net/ Yahoo!: dew7e
Jabber: Theory@jabber.org


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Bricolage-General mailing list
Bricolage-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bricolage-general
Re: [Bricolage-General] RE: date formatting [ In reply to ]
On Monday, September 23, 2002, at 03:31 PM, Philip Fibiger wrote:

> I looked through Data.pm in /Bric/Biz/Asset/Business/Parts/Tile and
> saw the
> added code for date formatting, but when I try to grab a formatted date
> string like this:
>
> if (my $pubdate = $element->get_data('publication_date',
> $format_string)) {
> $formatted_date = local_date($pubdate, "%B %Y");
> }
>
> the get_data returns nothing, and doesn't return an error, as far as I
> can
> tell. Any ideas about what i'm doing wrong?

Not offhand, but I *can* tell you that you don't want to call
local_date(). get_data() does that for you. So you can just do this:

my $formatted_date = $element->get_data('publication_date', "%B %Y");

HTH,

David

--
David Wheeler AIM: dwTheory
david@wheeler.net ICQ: 15726394
http://david.wheeler.net/ Yahoo!: dew7e
Jabber: Theory@jabber.org



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Bricolage-General mailing list
Bricolage-General@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bricolage-general