Created
September 28, 2016 11:39
-
-
Save croisillon/2bf129e2577558bd147dd4be9adb5819 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub days_inmonth_inyear { | |
my ( $x, $y ) = @_; | |
return 28 + ( ( $x + int( $x / 8 ) ) % 2 ) + 2 % $x + int( | |
( 1 | |
+ ( 1 - ( $y % 4 + 2 ) % ( $y % 4 + 1 ) ) | |
* ( ( $y % 100 + 2 ) % ( $y % 100 + 1 ) ) | |
+ ( 1 - ( $y % 400 + 2 ) % ( $y % 400 + 1 ) ) | |
) / $x | |
) + int( 1 / $x ) - int( | |
( ( 1 - ( $y % 4 + 2 ) % ( $y % 4 + 1 ) ) | |
* ( ( $y % 100 + 2 ) % ( $y % 100 + 1 ) ) | |
+ ( 1 - ( $y % 400 + 2 ) % ( $y % 400 + 1 ) ) | |
) / $x | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment