%doctype;
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <!-- $Id: calendar.txt,v 7.00 2015/03/09 11:13:43 mr Exp $ -->
  <title>[*calendar/calendars]1</title>
  <meta name="robots" content="none"%/>
  <meta name="format-detection" content="telephone=no"%/>
  <meta http-equiv="Content-Type" content="text/html; charset=%charset;"%/>
  <meta http-equiv="Content-Style-Type" content="text/css"%/>
  <link rel="shortcut icon" href="%image_prefix;/favicon_gwd.png"%/>
  %include.css;
  %base_header;
</head>
<body%body_prop;>
%message_to_wizard;

%if;not cancel_links;
  <div class="menu2">
    <a href="%prefix;" title="[visualize/show/hide/summary]3">^^</a>
  </div>
%end;

<h1>[*calendar/calendars]1</h1>

%define;french_day(xx)
  %apply;nth%with;
    /Primidi/Duodi/Tridi/Quartidi/Quintidi/Sextidi/Septidi/Octidi/Nonidi/Décadi/Primidi/Duodi/Tridi/Quartidi/Quintidi/Sextidi/Septidi/Octidi/Nonidi/Décadi/Primidi/Duodi/Tridi/Quartidi/Quintidi/Sextidi/Septidi/Octidi/Nonidi/Décadi/
  %and;xx%end;
%end;

%define;nb_days(xx)
  %apply;nth%with;
    /31/28/31/30/31/30/31/31/30/31/30/31%and;
    xx%end;
%end;

%define;compute_age1(z1,z2,z3)
  %if;(z1 > 0)
    %if;(z1 = 1)[one year old]%else;z1 [years old]%end;
    %if;(z2 > 0 or z3 > 0), %end;
  %end;
  %if;(z2 > 0)
    %if;(z2 = 1)[one month old]%else;z2 [months old]%end;
    %if;(z3 > 0), %end;
  %end;
  %if;(z3 > 0)
    %if;(z3 = 1)[one day old]%else;z3 [days old]%end;
  %end;
%end;

%define;compute_age(z1,z2)
  %let;l1;%apply;nb_days(z2.month)%in;
  %let;l2;%expr(z1.julian_day - z2.julian_day)%in;
  %if;(z1.month > z2.month)
    %if;(z1.day >= z2.day)
      %apply;compute_age1(z1.year - z2.year,z1.month - z2.month,z1.day - z2.day)
    %else;
      %apply;compute_age1(z1.year - z2.year,z1.month - z2.month - 1,l1 + z1.day - z2.day)
    %end;
  %end;
  %if;(z1.month = z2.month)
    %if;(z1.day >= z2.day)
      %apply;compute_age1(z1.year - z2.year,0,z1.day - z2.day)
    %else;
      %apply;compute_age1(z1.year - z2.year - 1,11,l1 + z1.day - z2.day)
    %end;
  %end;
  %if;(z1.month < z2.month)
    %if;(z1.day >= z2.day)
      %apply;compute_age1(z1.year - z2.year - 1,12 + z1.month - z2.month,z1.day - z2.day)
    %else;
      %apply;compute_age1(z1.year - z2.year - 1,11 + z1.month - z2.month,l1 + z1.day - z2.day)
    %end;
  %end;
  %if;(l2 > 31) (%l2; [days old])%end;
%end;

%define;fun_day(ccc, nnn)
  <td><input type="submit" name="dccc1" value="&lt;"%/></td>
  <td><input name="dccc" size="2" maxlength="2" value="%date.nnn.day;"%/></td>
  <td><input type="submit" name="dccc2" value="&gt;"%/></td>
%end;

%define;fun_month(ccc, nnn, vvv, lll)
  <td><input type="submit" name="mccc1" value="&lt;"%/></td>
  <td>
    <select name="mccc">
      %foreach;integer_range(1, vvv)
        <option value="%integer;"%nn;
         %if;(integer = date.nnn.month) selected="selected"%end;>%nn;
           %apply;nth("lll", integer-1)
        </option>
      %end;
    </select>
  </td>
  <td><input type="submit" name="mccc2" value="&gt;"%/></td>
%end;

%define;fun_year(ccc, nnn)
  <td><input type="submit" name="yccc1" value="&lt;"%/></td>
  <td><input name="yccc" size="6" maxlength="6" value="%date.nnn.year;"%/></td>
  <td><input type="submit" name="yccc2" value="&gt;"%/></td>
%end;

%define;fun_julian_year(ccc, nnn)
  %let;year;
    %if;(date.julian.month < 3 or
         date.julian.month = 3 and date.julian.day < 25)
      %expr(date.nnn.year - 1)/%expr(date.nnn.year % 10)
    %else;%date.nnn.year;%end;
  %in;
  <td><input type="submit" name="yccc1" value="&lt;"%/></td>
  <td><input name="yccc" size="6" maxlength="6" value="%year;"%/></td>
  <td><input type="submit" name="yccc2" value="&gt;"%/></td>
%end;

%define;calendar(ccc, nnn, vvv, lll, fun_yyy)
  %if;([ !dates order]0 = "ddmmyyyy")
    %apply;fun_day("ccc", "nnn")
    %apply;fun_month("ccc", "nnn", "vvv", "lll")
    %apply;fun_yyy("ccc", "nnn")
  %elseif;([ !dates order]0 = "mmddyyyy")
    %apply;fun_month("ccc", "nnn", "vvv", "lll")
    %apply;fun_day("ccc", "nnn")
    %apply;fun_yyy("ccc", "nnn")
  %else;
    %apply;fun_yyy("ccc", "nnn")
    %apply;fun_month("ccc", "nnn", "vvv", "lll")
    %apply;fun_day("ccc", "nnn")
  %end;
  <td><input type="submit" name="tccc" value="="%/></td>
%end;

<table id="calendar">
<tr>
  <td>
    <form method="get" action="%action;">
      <p>
        %hidden;
        <input type="hidden" name="m" value="CAL"%/>
      </p>
    <table>
    <tr>
      <td>&nbsp;</td>
      %if;([ !dates order] = "ddmmyyyy")
        <th colspan="3">[*year/month/day]2</th>
        <th colspan="3">[*year/month/day]1</th>
        <th colspan="3">[*year/month/day]0</th>
      %elseif;([ !dates order] = "mmddyyyy")
        <th colspan="3">[*year/month/day]1</th>
        <th colspan="3">[*year/month/day]2</th>
        <th colspan="3">[*year/month/day]0</th>
      %else;
        <th colspan="3">[*year/month/day]0</th>
        <th colspan="3">[*year/month/day]1</th>
        <th colspan="3">[*year/month/day]2</th>
      %end;
      <td>&nbsp;</td>
    </tr>
    <tr>
      <th>[*gregorian/julian/french/hebrew]0</th>
      %apply;calendar("g", "gregorian", 12, [(month)], "fun_year")
    </tr>
    <tr>
      <th>[*gregorian/julian/french/hebrew]1</th>
      %apply;calendar("j", "julian", 12, [(month)], "fun_julian_year")
    </tr>
    <tr>
      <th>[*gregorian/julian/french/hebrew]2</th>
      %apply;calendar("f", "french", 13, [(french revolution month)], "fun_year")
    </tr>
    <tr>
      <th>[*gregorian/julian/french/hebrew]3</th>
      %apply;calendar("h", "hebrew", 13, [(hebrew month)], "fun_year")
    </tr>
  </table>
  </form>
  </td>
</tr>
<tr>
<td>
  <ul>
    <li>
      %apply;capitalize%with;%apply;nth([(week day)], date.week_day)%end;
      %if;(date.julian_day = today.julian_day)%sp;%time;%end;
    </li>
    %if;(date.julian_day > 2375839)
      <li %if;(date.julian_day < 2380688)style="font-weight:bold;"%end;>
        %apply;french_day(date.french.day),%sp;%date.french.day;
        %sp;%apply;nth([(french revolution month)], date.french.month -1)
        %sp;an %date.french.year.roman; 
      </li>
    %end;
    <li>
      [*moon age/new moon/first quarter/full moon/last quarter]0 : %date.moon_age;
      %if;(date.moon_phase.index != 0)
        %sp;-%sp;
        %apply;capitalize%with;
          %apply;nth([moon age/new moon/first quarter/full moon/last quarter],
                     date.moon_phase.index) :%sp;
           %date.moon_phase.hour;:%date.moon_phase.minute; UT
        %end;
      %end;
    </li>
    %if;(date.julian_day > 1721425 and today.julian_day != date.julian_day)
      <li>[*age] :
        %if;(today.julian_day > date.julian_day)
          %apply;compute_age("today","date")
        %else;
          -%apply;compute_age("date","today")
        %end;
      </li>
    %end;
    <li>
      [*julian day] :%sp;
      %if;(date.julian_day < 1000)%date.julian_day;
      %else;%date.julian_day.sep1000;
      %end;
    </li>
  </ul>
  %if;(wizard or friend)
    <form method="get" action="%action;">
      <p>
      <a href="%prefix;m=STAT">[*statistics] :</a>%sp;
      %hidden;
      <input name="k" value="%if;(bvar.latest_event != "")%bvar.latest_event;%else;20%end;" size="5" maxlength="5" %/>
      <label>
        <input type="radio" name="m" value="LB" checked="checked" %/>
        [birth]
      </label>
      <label>
        <input type="radio" name="m" value="LM" %/>
        [marriage/marriages]0
      </label>
      <label>
        <input type="radio" name="m" value="LD" %/>
        [death]
      </label>
      … ([before (date)]…
        %if;([ !dates order]0 = "ddmmyyyy")
          <input name="bd" value="%expr(date.gregorian.day + 1)" size="2" maxlength="2" %/>
          <input name="bm" value="%date.gregorian.month;" size="2" maxlength="2" %/>
          <input name="by" value="%date.gregorian.year;" size="4" maxlength="4" %/>
        %elseif;([ !dates order]0 = "mmddyyyy")
          <input name="bm" value="%date.gregorian.month;" size="2" maxlength="2" %/>
          <input name="bd" value="%expr(date.gregorian.day + 1)" size="2" maxlength="2" %/>
          <input name="by" value="%date.gregorian.year;" size="4" maxlength="4" %/>
        %else;
          <input name="by" value="%date.gregorian.year;" size="4" maxlength="4" %/>
          <input name="bm" value="%date.gregorian.month;" size="2" maxlength="2" %/>
          <input name="bd" value="%expr(date.gregorian.day + 1)" size="2" maxlength="2" %/>
        %end;)
      <input type="submit" value="Ok" %/>
      </p>
    </form>
    %let;lang;
      %if;(evar.lang != "")
        %evar.lang;
      %elseif;(bvar.default_lang != "")
        %bvar.default_lang;
      %else;en%nn;
      %end;
    %in;
    <ul>
      <li>
        <a href="%prefix;m=POP_PYR;int=5;lim=0;y=%date.gregorian.year;">
          [population pyramid] (%date.gregorian.year;)
        </a>
      </li>
      <li>
        <a href="%prefix;m=AN;v=%date.gregorian.month;">
          [birthdays] (%apply;nth([(month)], date.gregorian.month-1))
        </a>
      </li>
      <li>
        <a href="%prefix;m=AD;v=%date.gregorian.month;">
          [anniversaries of dead people] (%apply;nth([(month)], date.gregorian.month-1))
        </a>
      </li>
      <li>
        <a href="%prefix;m=AM;v=%date.gregorian.month;">
          [anniversaries of marriage] (%apply;nth([(month)], date.gregorian.month-1))
        </a>
      </li>
    </ul>
    <ul>
      <li>
        <a href="http://%lang;.wikipedia.org/wiki/%date.gregorian.year;">
          http://%lang;.wikipedia.org/wiki/%date.gregorian.year;
        </a>
      </li>
      <li>
        <a href="http://%lang;.wikiwix.com/people/timeline.php?cyear=%date.gregorian.year;">
          http://%lang;.wikiwix.com/people/timeline.php?cyear=%date.gregorian.year;
        </a>
      </li>
    </ul>
  %end;
</td>
</tr>
</table>
%base_trailer;
%copyright;
</body>
</html>
