Before you head down that road, have you tried the
POSIX::strftime module/function yet? The strftime time & date conversion formats will handle anything you want to do with the date, without requiring you to reinvent the wheel... "%M" for example, is minute with leading 0s...