Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: day of year calculation

by fglock (Vicar)
on Feb 22, 2005 at 14:53 UTC ( #433351=note: print w/replies, xml ) Need Help??


in reply to Re: day of year calculation
in thread day of year calculation

1 less function call:

#!/usr/local/bin/perl use strict; sub dayofyear { my ($day1,$month,$year)=@_; my @cumul_d_in_m = (0,31,59,90,120,151,181,212,243,273,304,334,365); my $doy=$cumul_d_in_m[--$month]+$day1; return $doy if $month < 2; return $doy unless $year % 4 == 0; return ++$doy unless $year % 100 == 0; return $doy unless $year % 400 == 0; return ++$doy; } print dayofyear(10,3,2005)."\n"; print dayofyear(10,3,2004)."\n"; print dayofyear(10,2,2005)."\n"; print dayofyear(10,2,2004)."\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://433351]
help
Chatterbox?
[thezip]: So, we have a small deployment coming up soon for a project. What is the general name for the project management documentation that details the tasks and schedules/ sequences for the execution of the deployment?
[thezip]: Deployment checklist?

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-02-23 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (350 votes). Check out past polls.