]> git.madduck.net Git - etc/awesome.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

src/timetable: Break out leap_years_since function from doomsday
authordaurnimator <quae@daurnimator.com>
Wed, 24 Jul 2013 15:52:27 +0000 (11:52 -0400)
committerdaurnimator <quae@daurnimator.com>
Wed, 24 Jul 2013 15:52:27 +0000 (11:52 -0400)
src/timetable.lua

index c71c59bc25d737ebc27c60b0586b719dd1d25c8f..b58ad0f531cc8386904e5aca72a8d21445126e44 100644 (file)
@@ -27,9 +27,13 @@ local function month_length ( m , y )
        end
 end
 
+local function leap_years_since ( year )
+       return idiv ( year , 4 ) - idiv ( year , 100 ) + idiv ( year , 400 )
+end
+
 local function doomsday ( year )
        return ( 3 -- Tuesday
-               - 1 + year + idiv ( year , 4 ) - idiv ( year , 100 ) + idiv ( year , 400 ) )
+               - 1 + year + leap_years_since ( year ) )
                % 7 + 1
 end
 local doomsday_cache = setmetatable ( { } , {