Mailing List Archive

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
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
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
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@justatheory.com>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
>
>