Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: users

date formatting

 

 

Bricolage users RSS feed   Index | Next | Previous | View Threaded


zdravko.balorda at siix

Feb 9, 2010, 2:26 AM

Post #1 of 10 (1677 views)
Permalink
date formatting

Hi,

I am writing an RSS template that would produce rss output for a
category and date formatting is killing me. Any way that $story->get_publish_date
return date in RFC-822 format. Is date formating left on users?

Zdravko


zdravko.balorda at siix

Feb 9, 2010, 7:28 AM

Post #2 of 10 (1636 views)
Permalink
Re: date formatting [In reply to]

> return date in RFC-822 format. Is date formating left on users?

To make things worse, my strftime keeps saying that today is Sunday!?

:(
Zdravko


paulo at digitalcraftsmen

Feb 9, 2010, 7:35 AM

Post #3 of 10 (1630 views)
Permalink
Re: date formatting [In reply to]

Hi,

What do you need that the documentation on the Bric::Util::Time module
didn't show you ? I'll be happy to improve the documentation.

regards,

Paul

Zdravko Balorda wrote:
>
> Hi,
>
> I am writing an RSS template that would produce rss output for a
> category and date formatting is killing me. Any way that
> $story->get_publish_date
> return date in RFC-822 format. Is date formating left on users?
>
> Zdravko
>
>


david at kineticode

Feb 9, 2010, 9:10 AM

Post #4 of 10 (1630 views)
Permalink
Re: date formatting [In reply to]

On Feb 9, 2010, at 2:26 AM, Zdravko Balorda wrote:

> I am writing an RSS template that would produce rss output for a
> category and date formatting is killing me. Any way that $story->get_publish_date
> return date in RFC-822 format. Is date formating left on users?

Something like:

$story->get_publish_date('%a, %d %b %Y %H:%M:%S %z');

`perldoc DateTime` for more on the supported strftime formats.

Best,

David


zdravko.balorda at siix

Feb 9, 2010, 11:36 PM

Post #5 of 10 (1622 views)
Permalink
Re: date formatting [In reply to]

> What do you need that the documentation on the Bric::Util::Time module
> didn't show you ? I'll be happy to improve the documentation.
>


Beside that it's my first time using any Bric::Util package,
% use Bric::Util::Time ’:all’;
fails to include saying (bricolage 1.10.4. Do upgrade, I know. :):
Error during compilation of <anonymous component>: Unrecognized character \xE2 at (eval 78998) line 11, <GEN2844> line 637. Stack:
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Interp.pm:631] [/usr/local/lib/perl5/site_perl/5.8.8/Bric/Util/Burner/Mason.pm:355]
[/usr/local/lib/perl5/site_perl/5.8.8/Bric/Util/Burner.pm:1523]
[/usr/local/lib/perl5/site_perl/5.8.8/Bric/App/Callback/Profile/Template.pm:567]
[/usr/local/lib/perl5/site_perl/5.8.8/Bric/App/Callback/Profile/Template.pm:98]
[/usr/local/lib/perl5/site_perl/5.8.8/Params/CallbackRequest.pm:296]
[/usr/local/lib/perl5/site_perl/5.8.8/MasonX/Interp/WithCallbacks.pm:119]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/ApacheHandler.pm:868]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/ApacheHandler.pm:822]
[/usr/local/lib/perl5/site_perl/5.8.8/Bric/App/Handler.pm:314] [/dev/null:0]

Regards, Zdravko.

ps. I've missed that $story->get_publish_date accepts format as argument.
This fixes all of my problems. :)


david at kineticode

Feb 10, 2010, 9:20 AM

Post #6 of 10 (1616 views)
Permalink
Re: date formatting [In reply to]

On Feb 9, 2010, at 11:36 PM, Zdravko Balorda wrote:

>
>> What do you need that the documentation on the Bric::Util::Time module didn't show you ? I'll be happy to improve the documentation.
>
>
> Beside that it's my first time using any Bric::Util package,
> % use Bric::Util::Time :all;

Don't use smart quotes there.

> ps. I've missed that $story->get_publish_date accepts format as argument.
> This fixes all of my problems. :)

Great!

Best,

David


zdravko.balorda at siix

Jun 9, 2010, 11:34 PM

Post #7 of 10 (1399 views)
Permalink
Re: date formatting [In reply to]

Hi,

I am having a bit of trouble setting LC_ALL:
% use POSIX;
% use locale;
% setlocale(LC_ALL, "sl_SI.UTF-8");

works ok, (I've checked it in perl) but
Bricolage construct
<% $story->get_cover_date($datef) %> locale <% setlocale(LC_ALL) %>
seems to ignore it and keeps writing English dates.

Any hint?
Regards, Zdravko


bret at pectopah

Jun 10, 2010, 7:23 AM

Post #8 of 10 (1404 views)
Permalink
Re: date formatting [In reply to]

Hi Zdravko,


I've always used DateTime directly to format dates, like this:

$date = DateTime->from_epoch( epoch => $story->get_cover_date('%s'),
locale => $locale );

Then output $date with the format of your choice.:

<% $date->strftime($format) %>

Hope this helps,

Bret


On Thu, 2010-06-10 at 08:34 +0200, Zdravko Balorda wrote:
>
> Hi,
>
> I am having a bit of trouble setting LC_ALL:
> % use POSIX;
> % use locale;
> % setlocale(LC_ALL, "sl_SI.UTF-8");
>
> works ok, (I've checked it in perl) but
> Bricolage construct
> <% $story->get_cover_date($datef) %> locale <% setlocale(LC_ALL) %>
> seems to ignore it and keeps writing English dates.
>
> Any hint?
> Regards, Zdravko
>
>


--
Bret Dawson
Producer
Pectopah Productions Inc.
(416) 895-7635
bret [at] pectopah
www.pectopah.com


david at kineticode

Jun 10, 2010, 10:35 AM

Post #9 of 10 (1400 views)
Permalink
Re: date formatting [In reply to]

On Jun 9, 2010, at 11:34 PM, Zdravko Balorda wrote:

> I am having a bit of trouble setting LC_ALL:
> % use POSIX;
> % use locale;
> % setlocale(LC_ALL, "sl_SI.UTF-8");
>
> works ok, (I've checked it in perl) but
> Bricolage construct
> <% $story->get_cover_date($datef) %> locale <% setlocale(LC_ALL) %>
> seems to ignore it and keeps writing English dates.

From the DateTime documentation:

> Locales
> All the object methods which return names or abbreviations return data
> based on a locale. This is done by setting the locale when
> constructing a DateTime object. There is also a "DefaultLocale()"
> class method which may be used to set the default locale for all
> DateTime objects created. If this is not set, then "en_US" is used.

So I imagine you want to call `DateTime->DefaultLocale('sl_SI')` in the <%init> block of your root-level autohandler, and then set it back to "en_US" in a <%cleanup> block. Or if you just need the dates in non-English in one place, scope more appropriately.

Best,

David


zdravko.balorda at siix

Jun 10, 2010, 10:26 PM

Post #10 of 10 (1395 views)
Permalink
Re: date formatting [In reply to]

> So I imagine you want to call `DateTime->DefaultLocale('sl_SI')` in the <%init> block of your root-level autohandler, and then set it back to "en_US" in a <%cleanup> block. Or if you just need the dates in non-English in one place, scope more appropriately.
>

Thank you. It works. :)

Regards, Zdravko

Bricolage users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.