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

Mailing List Archive: Bricolage: users

Story->get_cover_date (minus x days)

 

 

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


bryancarney at gmail

Jul 18, 2012, 2:42 PM

Post #1 of 4 (1349 views)
Permalink
Story->get_cover_date (minus x days)

I had to go a bit roundabout to get the date in my desired format, but 7
days prior to a cover date because I can't find documentation on the
options of story->get_cover_date or an alternative

i.e.:

my $coverdate = $story->get_cover_date;
my $coverdateobj = str2time($coverdate);
my $coverdateobjweek = ($coverdateobj - (3600 * 24 * 7));
my $coverstring = time2str('%e %B %Y', $coverdateobjweek);


Can someone recommend some reading?

Thanks kindly,

Bryan


ps at phillipadsmith

Jul 18, 2012, 4:24 PM

Post #2 of 4 (1290 views)
Permalink
Re: Story->get_cover_date (minus x days) [In reply to]

On 2012-07-18, at 5:42 PM, Bryan Carney wrote:

> I had to go a bit roundabout to get the date in my desired format, but 7
> days prior to a cover date because I can't find documentation on the
> options of story->get_cover_date or an alternative
>
> i.e.:
>
> my $coverdate = $story->get_cover_date;
> my $coverdateobj = str2time($coverdate);
> my $coverdateobjweek = ($coverdateobj - (3600 * 24 * 7));
> my $coverstring = time2str('%e %B %Y', $coverdateobjweek);
>
>
> Can someone recommend some reading?


Sorry, are you trying to "get the cover date" ( $story->get_cover_date ) of a particular story, or something else?

All documented at http://bricolagecms.org/docs/current/api/ under Bric::Biz::Asset::Business::Story

Or, if you're trying to get a LIST of stories, look under Bric::Biz::Asset::Business::Story->list

Phillip.

--
Phillip Smith
http://phillipadsmith.com
http://twitter.com/phillipadsmith
http://linkedin.com/in/phillipadsmith

Save our in-boxes! http://emailcharter.org


david at justatheory

Jul 19, 2012, 4:40 AM

Post #3 of 4 (1278 views)
Permalink
Re: Story->get_cover_date (minus x days) [In reply to]

On Jul 18, 2012, at 11:42 PM, Bryan Carney wrote:

> I had to go a bit roundabout to get the date in my desired format, but 7
> days prior to a cover date because I can't find documentation on the
> options of story->get_cover_date or an alternative

You can pass a strftime format to get_cover_date. One of the options is "object", which will return the underlying DateTime object that you can then manipulate:

my $dt = $story->get_cover_date('object')->subtract(days => 7);
my $coverstring = $dt->strftime('%e %B %Y');

See the DateTime docs for all the details.

http://metacpan.org/module/DateTime

If you don't need to do date mat, you can just pass a strftime format to any accessor that returns a date:

$story->get_cover_date('%e %B %Y');

> Can someone recommend some reading?

See the documentation for "localdate" in Bric::Util::Time for details.

http://bricolagecms.org/docs/current/api/Bric::Util::Time

HTH,

David


bryancarney at gmail

Jul 19, 2012, 5:49 AM

Post #4 of 4 (1276 views)
Permalink
Re: Story->get_cover_date (minus x days) [In reply to]

Thanks guys -- getting as an object is the piece I was missing.

Cheers,

Bryan

On Thu, Jul 19, 2012 at 7:40 AM, David E. Wheeler <david [at] justatheory>wrote:

> On Jul 18, 2012, at 11:42 PM, Bryan Carney wrote:
>
> > I had to go a bit roundabout to get the date in my desired format, but 7
> > days prior to a cover date because I can't find documentation on the
> > options of story->get_cover_date or an alternative
>
> You can pass a strftime format to get_cover_date. One of the options is
> "object", which will return the underlying DateTime object that you can
> then manipulate:
>
> my $dt = $story->get_cover_date('object')->subtract(days => 7);
> my $coverstring = $dt->strftime('%e %B %Y');
>
> See the DateTime docs for all the details.
>
> http://metacpan.org/module/DateTime
>
> If you don't need to do date mat, you can just pass a strftime format to
> any accessor that returns a date:
>
> $story->get_cover_date('%e %B %Y');
>
> > Can someone recommend some reading?
>
> See the documentation for "localdate" in Bric::Util::Time for details.
>
> http://bricolagecms.org/docs/current/api/Bric::Util::Time
>
> HTH,
>
> David
>
>

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.