Skip to content
Categories:

CPAN Pull Request Challenge for January: DateTime::Format::Epoch

Post date:
Author:

About the challenge

About a week before Christmas I signed up for Neil Bowers 2015 CPAN Pull Request challenge. This is a challenge where each month you’d need to send a pull request to a module that would get assigned to you; and the idea is that you really need to make this one pull request each month. I thought it would be nice to see if I could pull it off.

It was only after I signed up that I realized the potential trouble I was getting myself into. I write lots of Perl, and also send pull requests if I find a problem in a module and I think I can fix it. For example, in the last month I sent a couple of pull requests in total and opened one issue on Github. Most of these are pretty minor things, maybe it’s a missing dependency, maybe it is improving the documentation a bit, or fixing a small bug. But this is in the Perl code I use, and this is always because it scratches an itch. And typically, this does not involve things like Moose – I never used Moose before in anger but there are quite a few modules out there on CPAN that do. And this time, Neil selects a module each month for you to send a pull request to. So if I’d got assigned a Moose-based module I’d have to investigate all that and this frightened me a little, so I sent Neil a reply stating this. More people asked similar questions and the end result is that if you think you can’t work on your assigned distribution for whatever reason  you can request a different module assignment.

HUGE number of participants!

Just before New Year, the Pull Request challenge was featured on Hacker News and really seemed to get traction. There are now over 300 people participating! I think this is awesome. There is a Google Group that is open for participants only, there is a thread where people introduce themselves. Some of the people who post there I know from within the Perl community, I have joined my local Amsterdam.PM and AmsterdamX.pm perl mongers groups at times, and met some people on FOSDEM as well. And some names I recognized because I’d have seen their names on CPAN on modules I use. But many of them are from people writing Perl code whose names I’ve not seen before, many people had no PAUSE ID and some even did not have a github account prior to joining. Also, people joined who wrote perl a while back, don’t use it in their day jobs anymore and who thought it’d be nice to get back at doing some perl stuff again. I think this is really nice, it’s great for the community. And for some people joining it introduces them to working with github and sending pull requests, which is also great!

My assignment for January

The module I got assigned is DateTime::Format::Epoch. It’s a formatter to use with the great DateTime module to easily load different epochs as DateTime objects, or outputting your DateTime object as different epochs. Of course handling the unix epoch is a core feature of DateTime but systems such as ActiveDirectory, .NET and TAI64 each have their own epochs, with differing precisions as well. For instance Active Directory has its epoch as the number of 100-nanoseconds intervals (1 nanosecond = one billionth of a second) since Jan 1, 1601 UTC.

First I looked at the module to see if I could spot some easy ones. I noticed the code example given in the POD documentation used ‘secondss’ instead of ‘seconds’ as a parameter name, that seemed odd! By installing the module and running a short test I very quickly found that this was not allowed; so I thought to have an easy pull request. But then I noticed the github repo was actually ahead of CPAN, and someone already made this pull request about a year ago. Then I looked into some of the open RT tickets, only to find out that most of them had been fixed already and marked as ‘patched’.

There were no things I felt comfortable about fixing left, and the documentation and tests seemed to be OK. I actually had a hard time thinking how I could contribute. Then I realized I could also expand the module. And I knew NTP uses its own epoch but there was no formatter for this. So I built one, added tests, and sent my pull request.

It allows you to use the result from an NTP server like this:

That example is a little contrived of course, it would be better to use a little higher level module such as Net::NTP instead of using Socket directly. And Net::NTP simply adds 2208988800 seconds to the NTP result and from there on threat it as a ‘regular’ epoch. This also fixes the problem; still I think the NTP formatter has its own use, not at the least because it looks easier and relieves the programmer from a little math and potential errors. But I’ll have to see and wait to find out if it will be accepted.

sees-pull-request-closes-with-no-comment-34ec44

The ‘receiving end’

I also have a few modules on CPAN myself, some of which I ‘adopted’ over the years. Plus, I have co-maint on DBD::mysql. I have not yet seen any pull requests on these modules this month so far, but I’ll see what happens and if I can possibly help or guide this person in any way. I’ll try to be a good maintainer!

Next months

All in all I really like it that there are now > 300 people who will be sending pull requests for modules on CPAN. If you’re a maintainer, please be kind and respond to the pull request in a helpful manner; and please understand that some of the people sending in pull requests never did this before!

To all participants: the CPAN pull request challenge uses a channel on IRC as well as a mailing list where people can support each other in case of questions. Please use it if you feel uncertain or just want some help or feedback. And best of luck!