Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts

Monday, April 5, 2010

ldap time to perl time()

This might save 30 seconds for someone else who wrongly thought that DateTime::Format:ISO8601 would parse an LDAP timestamp.

# Takes an ISO8601ish LDAP timestamp datatype and converts it into a perl time()
# compatible structure.  Requires Time::Local.
sub ldap2time
{
    my $ldap_ts = shift;
    return unless $ldap_ts =~ /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/;
    my ($year, $mon, $day, $hour, $min, $sec) = ($1, $2, $3, $4, $5, $6);
    return timegm($sec, $min, $hour, $day, ($mon-1), $year);
}

Sunday, May 3, 2009

Spring is Awesome

Long time, no post. That's mainly because winter in Wisconsin absolutely completely fucking sucks. Seriously.

But now it's spring, and all is much better. I've been giving the grill a good workout this weekend and I bought a bike from a local bike shop to better enjoy the town. It's been 15ish years since I had a bike and I forgot how damn much fun it is to ride around. It's also been a longer time since I road in an urban setting, so some re-learning of how to deal with traffic and streets has been interesting.

Among other recent springtime revelations: I think I'm starting to like perl more than php. We do lots of perl at work and afer doing perl and then hitting php again, it seemed really restrictive. I'm planning a personal php project to see if that's really true, or because my php skills are just really rusty.

Go Spring.