in reply to odd or even day?
Not quite sure what you mean by 'odd' and 'even'.
January 7 2006 is the 13,155th day since the start of the epoch. It is therefore 'odd' by your calculation (update: I should have written something like "by your calculation adjusted as per replies above"). However, January 7 2007 will be the 13,520th day, and therefore 'even'.
If that is what you want, fine, just ignore this post.
However, for a more normal definition of 'odd/even' - ie Jan 7 is odd, Jan 8 is even, Feb 1 is odd, Feb 2 is even, etc - you could do:
print +( localtime )[3] % 2 ? "odd\n" : "even\n";Or else, counting from the beginning of the year - ie March 1 is the 60th day (even) in a normal year, but the 61st day (odd) in a leap year:
print +( localtime )[7] % 2 ? "even\n" : "odd\n";
|
---|