get day number from date-time

Get day number (day of the year) from given date (i.e. time in epoch seconds)

Download getdayfromdate.zip

Synopsis:

getdayfromdate.pl


getdayfromdate.pl

Synopsis
#returns 1 to 365
sub GetDayFromDate($)
  {
  my ($t) = @_;
  return (localtime shift)[7] + 1;
  }

#-- unit tests
sub test_getdayfromdate()
  {
  ut::assert(GetDayFromDate(0), 365);
  ut::assert(GetDayFromDate(28799), 365);
  ut::assert(GetDayFromDate(28800), 1);
  ut::assert(GetDayFromDate(28800 + 60*60*24*365), 1);
  ut::assert(GetDayFromDate(28800 + 60*60*24*366), 2);
  ut::assert(GetDayFromDate(1096523422), 273);
  }

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