On Mon, 25 Oct 2004 15:40:12 -0400, Gavin Estey <[EMAIL PROTECTED]> wrote: > Drew Taylor wrote: > > In the template I wanted to take the stringified class_date object > > ("2004-10-25 09:00:00") and split on the white space to get the > > individual day and hour components. My first thought was: > > > > [day, time] = schedule.class_date.split(' '); > > > > What about being explicit and using strftime? > > day = schedule.class_date.strftime('%Y-%m-%d') > time = schedule.class_date.strftime('%H-%M-%S')
Interesting idea! This could be very useful in other places as well. > Also Class::Date seems an odd choice, I'm more familiar with Time::Piece. I have used Time::Piece in the past as well, but the CDBI wiki mentioned Class::Date so I thought I'd give it a try. For what I'm doing now I think I either one would work. The annoying thing about Time::Piece is that it likes to throw "found garbage at..." if you pass it more data than it's expecting. And the error message is spectacularly unhelpful if T::P can't parse the string. Drew -- ---------------------------------------------------------------- Drew Taylor * Web development & consulting Email: [EMAIL PROTECTED] * Site implementation & hosting Web : www.drewtaylor.com * perl/mod_perl/DBI/mysql/postgres ---------------------------------------------------------------- _______________________________________________ templates mailing list [EMAIL PROTECTED] http://lists.template-toolkit.org/mailman/listinfo/templates