datetime: factor out a common function
datetime: factor out a common function

The 'p' and 'P' cases are exactly the same, except for one line. Factor
out a common function for both.

https://bugzilla.gnome.org/show_bug.cgi?id=761889

johne53/MB3Glib,johne53/MB3Glib,johne53/MB3Glib,johne53/MB3Glib,endlessm/glib,endlessm/glib,endlessm/glib,johne53/MB3Glib,endlessm/glib,johne53/MB3Glib,endlessm/glib