Advanced

Re: Full calendar, without leap day

[Resolved] Full calendar, without leap day
June 11, 2017 09:25AM
I am currently trying to create a challenge where it's required to have a full calendar with Traditionals (found date/visitdate). Since it's not allowed to require leap day I want that date to be ignored.

From what I can see on the checker scripts they would all either require leap day (if set to 366 days), or make leap day optional if setting to 365, allowing another date to be empty instead.

I would like leap day to be ignored from the checker. Any checker that does this? Otherwise I will see if I can get pinkunicorn to patch his "Generic calendar checker".

To be clearer with the question itself. Did I miss a script that does what I want?
Re: Full calendar, without leap day
June 11, 2017 11:09AM
Use pinkunicorn's script with the following setting { "type": "Traditional Cache", "limit":1, "leapday":"allow"}
Re: Full calendar, without leap day
June 13, 2017 12:30PM
vogelbird Wrote:
-------------------------------------------------------
> Use pinkunicorn's script with the following
> setting { "type": "Traditional Cache", "limit":1,
> "leapday":"allow"}


Ah, if I use his script with leapday: allow and require 366 days I will get what I want?

I didn't realize, I have created a patch for his script that has an option for leapday that is "ignore". Maybe that isn't needed.
Re: Full calendar, without leap day
June 13, 2017 12:39PM
If you use my calendar checker and set needed = 365 it will require 365 out of the 366 dates to be filled and won't care which one is empty. This parameter is mostly useful when making a challenge for "fill 183 days" or something like that.

If you set needed = 366 and leapday = allow it will require 366 days if you have logged anything on leap day but will give you OK for 365 days if the missing day is leap day.

(If you set needed = 365 and leapday = allow it should still work right if you have not logged anything on leap day but if you have, it will count that and allow you a missed date somewhere else which is probably not what you want.)
Re: Full calendar, without leap day
June 13, 2017 12:54PM
It seems like it works as I want to if I just write the config as suggested (a bit weird to set needed to 366 when only 365 is needed though).

In case we would want my patch in the future, it's here:
--- 154.lua	2017-06-13 12:08:16.825498098 +0200
+++ 154-ganja1447.lua	2017-06-13 12:23:53.162355800 +0200
@@ -70,10 +70,11 @@
     conf.needed = ToNumber(conf.needed)
   end
 
-  if conf.leapday == "allow" then
-    conf.leapday = "false"
-  else
-    conf.leapday = "true"
+  -- allow = allow skipping leap day
+  -- ignore = don't count leap day at all
+  -- default = treat leap day as a normal day
+  if conf.leapday ~= "allow" and conf.leapday ~= "ignore" then
+    conf.leapday = "default"
   end
 
   if conf.placed == nil then
@@ -134,8 +135,10 @@
   local statustable = { }
 
   slog = numdone .. " dates of " .. conf.needed .. " completed. "
-  if conf.leapday == "false" then
+  if conf.leapday == "allow" then
     slog = slog .. "This challenge allows leap day to be skipped. "
+  elseif conf.leapday == "ignore" then
+    slog = slog .. "This challenge ignores leap day. "
   end
 
   -- Show what is done and what is missing.
@@ -169,7 +172,9 @@
             local diff = status[key] or 0
             diff = conf.limit - diff
             if ok == false then
-              if month == 2 and day == 29 and conf.leapday == "false" then
+              if month == 2 and day == 29 and conf.leapday == "ignore" then
+                TableInsert(statustable, '<td>X</td>')
+              elseif month == 2 and day == 29 and conf.leapday == "allow" then
                 TableInsert(statustable, '<td><span style="color:red">('
                                          .. diff .. ")</span></td>")
               else
@@ -177,7 +182,11 @@
                                          .. diff .. "</span></td>")
               end
             else
-              TableInsert(statustable, '<td></td>')
+              if month == 2 and day == 29 and conf.leapday == "ignore" then
+                TableInsert(statustable, '<td>X</td>')
+              else
+                TableInsert(statustable, '<td></td>')
+              end
             end
             TableInsert(missing, key)
           else
@@ -275,6 +284,10 @@
       end
     end
 
+    if conf.leapday == "ignore" and day == "02-29" then
+      day = "13-01"    -- Dummy date that will be ignored later.
+    end
+
     -- Keep track of number of types logged per day.
     -- Note: This does not consider ExcludedTypes.
     if notypes[day] == nil then
@@ -335,7 +348,7 @@
   local ok = false
   if numdone >= conf.needed
     or (numdone == conf.needed - 1
-    and conf.leapday == "false"
+    and conf.leapday == "allow"
     and (status[makekey(2,29)] == nil
       or (status[makekey(2,29)] ~= nil and status[makekey(2,29)] < conf.limit))
     ) then
Sorry, only registered users may post in this forum.

Click here to login