Module:Layout/Production/Library/Timestamp

Uit Wikibooks
 Deze module is nog in ontwikkeling (versie 0.0) en wordt getest.

De Module:Layout is bedoeld om snel, consistent en uitgebreid een pagina op te maken.
Er is een op de module afgestemde handleiding over deze onderwijswiki beschikbaar.

De module wordt geïnitialiseerd met de configuratie in Module:Layout/Production/Configuration.

Controleer op scriptfouten of opmaak notificaties.




local timestamp = {}

function timestamp.valid( day, month, year )
  -- Check if the year is a leap year.
  local isLeapYear = year % 4 == 0 and (year % 100 ~= 0 or year % 400 == 0);

  -- Check if the day is within the valid range for the given month and year.
  local daysInMonth = {31, isLeapYear and 29 or 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  
  -- If the day is less or equal then the maximum for the given month the date is ok.
  return day <= daysInMonth[ month ];
end

return timestamp;
Informatie afkomstig van https://nl.wikibooks.org Wikibooks NL.
Wikibooks NL is onderdeel van de wikimediafoundation.