Get month number from date
Download getmonthfromdate.zip
Synopsis: |
| getmonthfromdate.pl |
| ||
#returns 1..12
sub GetMonthFromDate($)
{
my ($t) = @_;
return (localtime shift)[4]+1;
}
#-- unit tests
sub test_getmonthfromdate()
{
ut::assert(GetMonthFromDate(0), 12);
ut::assert(GetMonthFromDate(28799), 12);
ut::assert(GetMonthFromDate(28800), 1); #28800 seconds is 8 hours
ut::assert(GetMonthFromDate(1056523422), 6);
ut::assert(GetMonthFromDate(1096523422), 9);
}
1;
|
| Contact me about content on this page using john_web-at-arrizza-dot-com |
| For Web Master or site problems contact: webadmin-at-arrizza-dot-com |
| Copyright John Arrizza (c) 2001-2010 |