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

Mailing List Archive: Bricolage: users

Date Formatting Help

 

 

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


smith_t at denison

Jul 10, 2008, 12:31 PM

Post #1 of 7 (216 views)
Permalink
Date Formatting Help

Hey all,

Even though Bricolage provides a nice way for us to format the date I
am having an impossible time trying to figure out how to just return a
UTC compliant date/time from a date input field. I need to use it to
render an UNTIL time in my Recurrence Rule. I probably just missed
something simple, hope someone can help.

-Trevor


david at kineticode

Jul 10, 2008, 3:48 PM

Post #2 of 7 (200 views)
Permalink
Re: Date Formatting Help [In reply to]

On Jul 10, 2008, at 12:31, Trevor Smith wrote:

> Even though Bricolage provides a nice way for us to format the date I
> am having an impossible time trying to figure out how to just return a
> UTC compliant date/time from a date input field. I need to use it to
> render an UNTIL time in my Recurrence Rule. I probably just missed
> something simple, hope someone can help.


For a date field, I believe it's:

$field->get_value(undef, Bric::Config::ISO_8601_FORMAT);

For an attribute, like cover_date, its:

$story->get_cover_date(Bric::Config::ISO_8601_FORMAT);

HTH,

David


smith_t at denison

Jul 11, 2008, 6:10 AM

Post #3 of 7 (201 views)
Permalink
Re: Date Formatting Help [In reply to]

Thanks for the info, however it doesn't seem to be working for me.
This is my initial line of code:
$enddate = $element->get_field('end_date')->get_value();
OUTPUT => 2002-01-07 00:00:00

And then this is then line with what you gave me, just in case I
formatted it wrong:
$enddate = $element->get_field('end_date')->get_value(undef,
Bric::Config::ISO_8601_FORMAT);
OUTPUT => 2002-01-07 00:00:00

So this doesn't seem to be working for me. Any other suggestions? Thanks.

-Trevor

On Thu, Jul 10, 2008 at 6:48 PM, David E. Wheeler <david[at]kineticode.com> wrote:
> On Jul 10, 2008, at 12:31, Trevor Smith wrote:
>
>> Even though Bricolage provides a nice way for us to format the date I
>> am having an impossible time trying to figure out how to just return a
>> UTC compliant date/time from a date input field. I need to use it to
>> render an UNTIL time in my Recurrence Rule. I probably just missed
>> something simple, hope someone can help.
>
>
> For a date field, I believe it's:
>
> $field->get_value(undef, Bric::Config::ISO_8601_FORMAT);
>
> For an attribute, like cover_date, its:
>
> $story->get_cover_date(Bric::Config::ISO_8601_FORMAT);
>
> HTH,
>
> David
>


david at kineticode

Jul 11, 2008, 8:55 AM

Post #4 of 7 (201 views)
Permalink
Re: Date Formatting Help [In reply to]

On Jul 11, 2008, at 06:10, Trevor Smith wrote:

> Thanks for the info, however it doesn't seem to be working for me.
> This is my initial line of code:
> $enddate = $element->get_field('end_date')->get_value();
> OUTPUT => 2002-01-07 00:00:00
>
> And then this is then line with what you gave me, just in case I
> formatted it wrong:
> $enddate = $element->get_field('end_date')->get_value(undef,
> Bric::Config::ISO_8601_FORMAT);
> OUTPUT => 2002-01-07 00:00:00
>
> So this doesn't seem to be working for me. Any other suggestions?
> Thanks.

How is that not UTC compliant? Do you need the T?

get_value( undef, '%Y-%m-%dT%H:%M:%S' );

`perldoc DateTime` and read up on strftime formatting for more.

Best,

David

Best,

David


smith_t at denison

Jul 11, 2008, 9:03 AM

Post #5 of 7 (201 views)
Permalink
Re: Date Formatting Help [In reply to]

Okay, perhaps I am asking for the wrong thing, I am trying to meet
this compliance standard:
http://www.kanzaki.com/docs/ical/dateTime.html

Which they refer to as UTC compliance.

T

On Fri, Jul 11, 2008 at 11:55 AM, David E. Wheeler <david[at]kineticode.com> wrote:
> On Jul 11, 2008, at 06:10, Trevor Smith wrote:
>
>> Thanks for the info, however it doesn't seem to be working for me.
>> This is my initial line of code:
>> $enddate = $element->get_field('end_date')->get_value();
>> OUTPUT => 2002-01-07 00:00:00
>>
>> And then this is then line with what you gave me, just in case I
>> formatted it wrong:
>> $enddate = $element->get_field('end_date')->get_value(undef,
>> Bric::Config::ISO_8601_FORMAT);
>> OUTPUT => 2002-01-07 00:00:00
>>
>> So this doesn't seem to be working for me. Any other suggestions?
>> Thanks.
>
> How is that not UTC compliant? Do you need the T?
>
> get_value( undef, '%Y-%m-%dT%H:%M:%S' );
>
> `perldoc DateTime` and read up on strftime formatting for more.
>
> Best,
>
> David
>
> Best,
>
> David
>
>


david at kineticode

Jul 11, 2008, 9:18 AM

Post #6 of 7 (200 views)
Permalink
Re: Date Formatting Help [In reply to]

On Jul 11, 2008, at 09:03, Trevor Smith wrote:

> Okay, perhaps I am asking for the wrong thing, I am trying to meet
> this compliance standard:
> http://www.kanzaki.com/docs/ical/dateTime.html
>
> Which they refer to as UTC compliance.

Sorry, reading the docs, I see that the first `undef` isn't required
in get_value(). Here is a format that should work:

get_value( '%Y%m%dT%H%M%SZ' );

Unfortunately, that will get you the date in the time zone set up as
the global system preferred time zone, which probably isn't UTC.
FBOFW, you have to convert it back into a DateTime object to get that:

Bric::Util::Time::datetime( $f->get_value )->set_time_zone('UTC')-
>strftime('%Y%m%dT%H%M%SZ')

We should add a datetime() method to Field.pm. Anyone want to take
that on?

HTH,

David


smith_t at denison

Jul 11, 2008, 10:15 AM

Post #7 of 7 (201 views)
Permalink
Re: Date Formatting Help [In reply to]

Thanks for the help!

T

On Fri, Jul 11, 2008 at 12:18 PM, David E. Wheeler <david[at]kineticode.com> wrote:
> On Jul 11, 2008, at 09:03, Trevor Smith wrote:
>
>> Okay, perhaps I am asking for the wrong thing, I am trying to meet
>> this compliance standard:
>> http://www.kanzaki.com/docs/ical/dateTime.html
>>
>> Which they refer to as UTC compliance.
>
> Sorry, reading the docs, I see that the first `undef` isn't required in
> get_value(). Here is a format that should work:
>
> get_value( '%Y%m%dT%H%M%SZ' );
>
> Unfortunately, that will get you the date in the time zone set up as the
> global system preferred time zone, which probably isn't UTC. FBOFW, you have
> to convert it back into a DateTime object to get that:
>
> Bric::Util::Time::datetime( $f->get_value
> )->set_time_zone('UTC')->strftime('%Y%m%dT%H%M%SZ')
>
> We should add a datetime() method to Field.pm. Anyone want to take that on?
>
> HTH,
>
> David
>

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


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.