1582. Október-óta használjuk a Gergely-naptárt.XIII. Gergely pápa 1581 februárjában, azaz a mai átszámolás szerinti 1582 februárjában (Lilius csillagász és Clavius matematikus javaslatai alapján) rendelte el az idõszámítás kiigazítását.A kiigazítást követõen, úgy rendelkezett, hogy 1582-es naptár, október 4. után azonnal október 15. következzék,A Gergely-naptár 1582. október 4-én csütörtökön lépett életbe oly módon, hogy az azt követõ nap október 15., péntek lett, a kettõ közötti naptár napok abban az évben kimaradtak.A másik intézkedéssel csökkentette a szökõnapok számát úgy, hogy a százas naptári évekbõl, csak 400-zal maradék nélkül oszthatóakban hagyta meg a szökõnapot (ezért 1700, 1800, 1900-as naptár, nem volt szökõév, de 2000-es naptár igen).A Gergely-naptár bevezetését követõen, az évek kezdete is megváltozott: Március 01-helyett Január 01. lettAz évek kezdeti idõpontváltozása azt eredményezte, hogy 1582. év, 10 hónaposra zsugorodott. (Január és Február kimaradt)A 400 évenként pluszban számított majdnem 3 órák ugyanis 8 ilyen ciklus alatt felduzzadnak egy szinte egész napra, azaz nagyjából 8x400=3200 évenként egy - egyébként szökõévbõl - a szökõnapot el kell hagyni.Mivel, ez a naptár számítási rendszer 1582-ben indult el, erre a szökõnap nélküli szökõévre elsõként valamikor 4800-as naptár táján kerülhet sor.[/quote]Az egészet átírtam pawn kódba:(Az 1582-es évet kihagytam belõle, a kódban feleslegesen szerepelne kihasználatlanság miatt, és kicsit komplikáltabb a többinél.)A kód 1583-tól 2068-ig megállapítja milyen napra esik a megadott dátum.A kód: stockGergelyCalendar(year, month, day){//year 1583 - 2068enum { JAN,FEB,MAR,APR,MAJ,JUN,JUL,AUG,SEP,OKT,NOV,DEC };staticDay_name[][10] = { {\"Hétfõ\"}, {\"Kedd\"}, {\"Szerda\"}, {\"Csütörtök\"}, {\"Péntek\"}, {\"Szombat\"}, {\"Vasárnap\"} };newd_[12],index;switch(year){case 1585,1613,1641,1669,1697,1709,1737,1765,1793,1805,1833,1861,1889,1901,1929,1957,1985,2013,2041: index = 1;case 1586,1614,1642,1670,1698,1710,1738,1766,1794,1806,1834,1862,1890,1902,1930,1958,1986,2014,2042: index = 2;case 1587,1615,1643,1671,1699,1711,1739,1767,1795,1807,1835,1863,1891,1903,1931,1959,1987,2015,2043: index = 3;case 1588,1616,1644,1672,1712,1740,1768,1796,1808,1836,1864,1892,1904,1932,1960,1988,2016,2044: index = 44;case 1700: index = 4;case 1589,1617,1645,1673,1713,1741,1769,1797,1809,1837,1865,1893,1905,1933,1961,1989,2017,2045: index = 6;case 1590,1618,1646,1674,1714,1742,1770,1798,1810,1838,1866,1894,1906,1934,1962,1990,2018,2046: index = 0;case 1591,1619,1647,1675,1715,1743,1771,1799,1811,1839,1867,1895,1907,1935,1963,1991,2019,2047: index = 1;case 1592,1620,1648,1676,1716,1744,1772,1812,1840,1868,1896,1908,1936,1964,1992,2020,2048: index = 42;case 1593,1621,1649,1677,1717,1745,1773,1813,1841,1869,1897,1909,1937,1965,1993,2021,2049: index = 4;case 1594,1622,1650,1678,1718,1746,1774,1814,1842,1870,1898,1910,1938,1966,1994,2022,2050: index = 5;case 1595,1623,1651,1679,1719,1747,1775,1815,1843,1871,1899,1911,1939,1967,1995,2023,2051: index = 6;case 1596,1624,1652,1680,1720,1748,1776,1816,1844,1872,1912,1940,1968,1996,2024,2052: index = 40;case 1900: index = 0;case 1597,1625,1653,1681,1721,1749,1777,1817,1845,1873,1913,1941,1969,1997,2025,2053: index = 2;case 1598,1626,1654,1682,1722,1750,1778,1818,1846,1874,1914,1942,1970,1998,2026,2054: index = 3;case 1599,1627,1655,1683,1723,1751,1779,1819,1847,1875,1915,1943,1971,1999,2027,2055: index = 4;case 1600,1628,1656,1684,1724,1752,1780,1820,1848,1876,1916,1944,1972,2000,2028,2056: index = 45;case 1601,1629,1657,1685,1725,1753,1781,1821,1849,1877,1917,1945,1973,2001,2029,2057: index = 0;case 1602,1630,1658,1686,1726,1754,1782,1822,1850,1878,1918,1946,1974,2002,2030,2058: index = 1;case 1603,1631,1659,1687,1727,1755,1783,1823,1851,1879,1919,1947,1975,2003,2031,2059: index = 2;case 1604,1632,1660,1688,1728,1756,1784,1824,1852,1880,1920,1948,1976,2004,2032,2060: index = 43;case 1605,1633,1661,1689,1701,1729,1757,1785,1825,1853,1881,1921,1949,1977,2005,2033,2061: index = 5;case 1606,1634,1662,1690,1702,1730,1758,1786,1826,1854,1882,1922,1950,1978,2006,2034,2062: index = 6;case 1607,1635,1663,1691,1703,1731,1759,1787,1827,1855,1883,1923,1951,1979,2007,2035,2063: index = 0;case 1608,1636,1664,1692,1704,1732,1760,1788,1828,1856,1884,1924,1952,1980,2008,2036,2064: index = 41;case 1800: index = 1;case 1609,1637,1665,1693,1705,1733,1761,1789,1801,1829,1857,1885,1925,1953,1981,2009,2037,2065: index = 3;case 1610,1638,1666,1694,1706,1734,1762,1790,1802,1830,1858,1886,1926,1954,1982,2010,2038,2066: index = 4;case 1583,1611,1639,1667,1695,1707,1735,1763,1791,1803,1831,1859,1887,1927,1955,1983,2011,2039,2067: index = 5;case 1584,1612,1640,1668,1696,1708,1736,1764,1792,1804,1832,1860,1888,1928,1956,1984,2012,2040,2068: index = 46;}month--;switch(index){case 0: { d_[JAN] = d_[OKT] = 0; d_[FEB] = d_[MAR] = d_[NOV] = 3; d_[APR] = d_[JUL] = 6; d_[MAJ] = 1; d_[JUN] = 4; d_[AUG] = 2; d_[sEP] = d_[DEC] = 5; index = d_[month]; }case 1: { d_[JAN] = d_[OKT] = 1; d_[FEB] = d_[MAR] = d_[NOV] = 4; d_[APR] = d_[JUL] = 0; d_[MAJ] = 2; d_[JUN] = 5; d_[AUG] = 3; d_[sEP] = d_[DEC] = 6; index = d_[month]; }case 2: { d_[JAN] = d_[OKT] = 2; d_[FEB] = d_[MAR] = d_[NOV] = 5; d_[APR] = d_[JUL] = 1; d_[MAJ] = 3; d_[JUN] = 6; d_[AUG] = 4; d_[sEP] = d_[DEC] = 0; index = d_[month]; }case 3: { d_[JAN] = d_[OKT] = 3; d_[FEB] = d_[MAR] = d_[NOV] = 6; d_[APR] = d_[JUL] = 2; d_[MAJ] = 4; d_[JUN] = 0; d_[AUG] = 5; d_[sEP] = d_[DEC] = 1; index = d_[month]; }case 4: { d_[JAN] = d_[OKT] = 4; d_[FEB] = d_[MAR] = d_[NOV] = 0; d_[APR] = d_[JUL] = 3; d_[MAJ] = 5; d_[JUN] = 1; d_[AUG] = 6; d_[sEP] = d_[DEC] = 2; index = d_[month]; }case 5: { d_[JAN] = d_[OKT] = 5; d_[FEB] = d_[MAR] = d_[NOV] = 1; d_[APR] = d_[JUL] = 4; d_[MAJ] = 6; d_[JUN] = 2; d_[AUG] = 0; d_[sEP] = d_[DEC] = 3; index = d_[month]; }case 6: { d_[JAN] = d_[OKT] = 6; d_[FEB] = d_[MAR] = d_[NOV] = 2; d_[APR] = d_[JUL] = 5; d_[MAJ] = 0; d_[JUN] = 3; d_[AUG] = 1; d_[sEP] = d_[DEC] = 4; index = d_[month]; }case 40: { d_[JAN] = d_[APR] = d_[JUL] = 0; d_[FEB] = d_[AUG] = 3; d_[MAR] = d_[NOV] = 4; d_[MAJ] = 2; d_[JUN] = 5; d_[OKT] = 1; d_[sEP] = d_[DEC] = 6; index = d_[month]; }case 41: { d_[JAN] = d_[APR] = d_[JUL] = 1; d_[FEB] = d_[AUG] = 4; d_[MAR] = d_[NOV] = 5; d_[MAJ] = 3; d_[JUN] = 6; d_[OKT] = 2; d_[sEP] = d_[DEC] = 0; index = d_[month]; }case 42: { d_[JAN] = d_[APR] = d_[JUL] = 2; d_[FEB] = d_[AUG] = 5; d_[MAR] = d_[NOV] = 6; d_[MAJ] = 4; d_[JUN] = 0; d_[OKT] = 3; d_[sEP] = d_[DEC] = 1; index = d_[month]; }case 43: { d_[JAN] = d_[APR] = d_[JUL] = 3; d_[FEB] = d_[AUG] = 6; d_[MAR] = d_[NOV] = 0; d_[MAJ] = 5; d_[JUN] = 1; d_[OKT] = 4; d_[sEP] = d_[DEC] = 2; index = d_[month]; }case 44: { d_[JAN] = d_[APR] = d_[JUL] = 4; d_[FEB] = d_[AUG] = 0; d_[MAR] = d_[NOV] = 1; d_[MAJ] = 6; d_[JUN] = 2; d_[OKT] = 5; d_[sEP] = d_[DEC] = 3; index = d_[month]; }case 45: { d_[JAN] = d_[APR] = d_[JUL] = 5; d_[FEB] = d_[AUG] = 1; d_[MAR] = d_[NOV] = 2; d_[MAJ] = 0; d_[JUN] = 3; d_[OKT] = 6; d_[sEP] = d_[DEC] = 4; index = d_[month]; }case 46: { d_[JAN] = d_[APR] = d_[JUL] = 6; d_[FEB] = d_[AUG] = 2; d_[MAR] = d_[NOV] = 3; d_[MAJ] = 1; d_[JUN] = 4; d_[OKT] = 0; d_[sEP] = d_[DEC] = 5; index = d_[month]; }}index = ((index + day) % 7) - 1;return Day_name[(0 <= index <= 6)?(index):(0)]; // Egy kis biztonság beleépítve, mivel nem teszteltem le minden egyes napra, és érvénytelen dátum megadásakor lefagyhatott.} Példa a használatra: newyear,month,day;getdate(year, month, day);printf(\"%d.%d.%d. -> %s\", year, month, day, GergelyCalendar(year, month, day)); Eredmény: 2012.5.17. -> Csütörtök [/quote]Sebesség tesztet nem végeztem, szerintem felesleges is.
stockGergelyCalendar(year, month, day){//year 1583 - 2068enum { JAN,FEB,MAR,APR,MAJ,JUN,JUL,AUG,SEP,OKT,NOV,DEC };staticDay_name[][10] = { {\"Hétfõ\"}, {\"Kedd\"}, {\"Szerda\"}, {\"Csütörtök\"}, {\"Péntek\"}, {\"Szombat\"}, {\"Vasárnap\"} };newd_[12],index;switch(year){case 1585,1613,1641,1669,1697,1709,1737,1765,1793,1805,1833,1861,1889,1901,1929,1957,1985,2013,2041: index = 1;case 1586,1614,1642,1670,1698,1710,1738,1766,1794,1806,1834,1862,1890,1902,1930,1958,1986,2014,2042: index = 2;case 1587,1615,1643,1671,1699,1711,1739,1767,1795,1807,1835,1863,1891,1903,1931,1959,1987,2015,2043: index = 3;case 1588,1616,1644,1672,1712,1740,1768,1796,1808,1836,1864,1892,1904,1932,1960,1988,2016,2044: index = 44;case 1700: index = 4;case 1589,1617,1645,1673,1713,1741,1769,1797,1809,1837,1865,1893,1905,1933,1961,1989,2017,2045: index = 6;case 1590,1618,1646,1674,1714,1742,1770,1798,1810,1838,1866,1894,1906,1934,1962,1990,2018,2046: index = 0;case 1591,1619,1647,1675,1715,1743,1771,1799,1811,1839,1867,1895,1907,1935,1963,1991,2019,2047: index = 1;case 1592,1620,1648,1676,1716,1744,1772,1812,1840,1868,1896,1908,1936,1964,1992,2020,2048: index = 42;case 1593,1621,1649,1677,1717,1745,1773,1813,1841,1869,1897,1909,1937,1965,1993,2021,2049: index = 4;case 1594,1622,1650,1678,1718,1746,1774,1814,1842,1870,1898,1910,1938,1966,1994,2022,2050: index = 5;case 1595,1623,1651,1679,1719,1747,1775,1815,1843,1871,1899,1911,1939,1967,1995,2023,2051: index = 6;case 1596,1624,1652,1680,1720,1748,1776,1816,1844,1872,1912,1940,1968,1996,2024,2052: index = 40;case 1900: index = 0;case 1597,1625,1653,1681,1721,1749,1777,1817,1845,1873,1913,1941,1969,1997,2025,2053: index = 2;case 1598,1626,1654,1682,1722,1750,1778,1818,1846,1874,1914,1942,1970,1998,2026,2054: index = 3;case 1599,1627,1655,1683,1723,1751,1779,1819,1847,1875,1915,1943,1971,1999,2027,2055: index = 4;case 1600,1628,1656,1684,1724,1752,1780,1820,1848,1876,1916,1944,1972,2000,2028,2056: index = 45;case 1601,1629,1657,1685,1725,1753,1781,1821,1849,1877,1917,1945,1973,2001,2029,2057: index = 0;case 1602,1630,1658,1686,1726,1754,1782,1822,1850,1878,1918,1946,1974,2002,2030,2058: index = 1;case 1603,1631,1659,1687,1727,1755,1783,1823,1851,1879,1919,1947,1975,2003,2031,2059: index = 2;case 1604,1632,1660,1688,1728,1756,1784,1824,1852,1880,1920,1948,1976,2004,2032,2060: index = 43;case 1605,1633,1661,1689,1701,1729,1757,1785,1825,1853,1881,1921,1949,1977,2005,2033,2061: index = 5;case 1606,1634,1662,1690,1702,1730,1758,1786,1826,1854,1882,1922,1950,1978,2006,2034,2062: index = 6;case 1607,1635,1663,1691,1703,1731,1759,1787,1827,1855,1883,1923,1951,1979,2007,2035,2063: index = 0;case 1608,1636,1664,1692,1704,1732,1760,1788,1828,1856,1884,1924,1952,1980,2008,2036,2064: index = 41;case 1800: index = 1;case 1609,1637,1665,1693,1705,1733,1761,1789,1801,1829,1857,1885,1925,1953,1981,2009,2037,2065: index = 3;case 1610,1638,1666,1694,1706,1734,1762,1790,1802,1830,1858,1886,1926,1954,1982,2010,2038,2066: index = 4;case 1583,1611,1639,1667,1695,1707,1735,1763,1791,1803,1831,1859,1887,1927,1955,1983,2011,2039,2067: index = 5;case 1584,1612,1640,1668,1696,1708,1736,1764,1792,1804,1832,1860,1888,1928,1956,1984,2012,2040,2068: index = 46;}month--;switch(index){case 0: { d_[JAN] = d_[OKT] = 0; d_[FEB] = d_[MAR] = d_[NOV] = 3; d_[APR] = d_[JUL] = 6; d_[MAJ] = 1; d_[JUN] = 4; d_[AUG] = 2; d_[sEP] = d_[DEC] = 5; index = d_[month]; }case 1: { d_[JAN] = d_[OKT] = 1; d_[FEB] = d_[MAR] = d_[NOV] = 4; d_[APR] = d_[JUL] = 0; d_[MAJ] = 2; d_[JUN] = 5; d_[AUG] = 3; d_[sEP] = d_[DEC] = 6; index = d_[month]; }case 2: { d_[JAN] = d_[OKT] = 2; d_[FEB] = d_[MAR] = d_[NOV] = 5; d_[APR] = d_[JUL] = 1; d_[MAJ] = 3; d_[JUN] = 6; d_[AUG] = 4; d_[sEP] = d_[DEC] = 0; index = d_[month]; }case 3: { d_[JAN] = d_[OKT] = 3; d_[FEB] = d_[MAR] = d_[NOV] = 6; d_[APR] = d_[JUL] = 2; d_[MAJ] = 4; d_[JUN] = 0; d_[AUG] = 5; d_[sEP] = d_[DEC] = 1; index = d_[month]; }case 4: { d_[JAN] = d_[OKT] = 4; d_[FEB] = d_[MAR] = d_[NOV] = 0; d_[APR] = d_[JUL] = 3; d_[MAJ] = 5; d_[JUN] = 1; d_[AUG] = 6; d_[sEP] = d_[DEC] = 2; index = d_[month]; }case 5: { d_[JAN] = d_[OKT] = 5; d_[FEB] = d_[MAR] = d_[NOV] = 1; d_[APR] = d_[JUL] = 4; d_[MAJ] = 6; d_[JUN] = 2; d_[AUG] = 0; d_[sEP] = d_[DEC] = 3; index = d_[month]; }case 6: { d_[JAN] = d_[OKT] = 6; d_[FEB] = d_[MAR] = d_[NOV] = 2; d_[APR] = d_[JUL] = 5; d_[MAJ] = 0; d_[JUN] = 3; d_[AUG] = 1; d_[sEP] = d_[DEC] = 4; index = d_[month]; }case 40: { d_[JAN] = d_[APR] = d_[JUL] = 0; d_[FEB] = d_[AUG] = 3; d_[MAR] = d_[NOV] = 4; d_[MAJ] = 2; d_[JUN] = 5; d_[OKT] = 1; d_[sEP] = d_[DEC] = 6; index = d_[month]; }case 41: { d_[JAN] = d_[APR] = d_[JUL] = 1; d_[FEB] = d_[AUG] = 4; d_[MAR] = d_[NOV] = 5; d_[MAJ] = 3; d_[JUN] = 6; d_[OKT] = 2; d_[sEP] = d_[DEC] = 0; index = d_[month]; }case 42: { d_[JAN] = d_[APR] = d_[JUL] = 2; d_[FEB] = d_[AUG] = 5; d_[MAR] = d_[NOV] = 6; d_[MAJ] = 4; d_[JUN] = 0; d_[OKT] = 3; d_[sEP] = d_[DEC] = 1; index = d_[month]; }case 43: { d_[JAN] = d_[APR] = d_[JUL] = 3; d_[FEB] = d_[AUG] = 6; d_[MAR] = d_[NOV] = 0; d_[MAJ] = 5; d_[JUN] = 1; d_[OKT] = 4; d_[sEP] = d_[DEC] = 2; index = d_[month]; }case 44: { d_[JAN] = d_[APR] = d_[JUL] = 4; d_[FEB] = d_[AUG] = 0; d_[MAR] = d_[NOV] = 1; d_[MAJ] = 6; d_[JUN] = 2; d_[OKT] = 5; d_[sEP] = d_[DEC] = 3; index = d_[month]; }case 45: { d_[JAN] = d_[APR] = d_[JUL] = 5; d_[FEB] = d_[AUG] = 1; d_[MAR] = d_[NOV] = 2; d_[MAJ] = 0; d_[JUN] = 3; d_[OKT] = 6; d_[sEP] = d_[DEC] = 4; index = d_[month]; }case 46: { d_[JAN] = d_[APR] = d_[JUL] = 6; d_[FEB] = d_[AUG] = 2; d_[MAR] = d_[NOV] = 3; d_[MAJ] = 1; d_[JUN] = 4; d_[OKT] = 0; d_[sEP] = d_[DEC] = 5; index = d_[month]; }}index = ((index + day) % 7) - 1;return Day_name[(0 <= index <= 6)?(index):(0)]; // Egy kis biztonság beleépítve, mivel nem teszteltem le minden egyes napra, és érvénytelen dátum megadásakor lefagyhatott.}
newyear,month,day;getdate(year, month, day);printf(\"%d.%d.%d. -> %s\", year, month, day, GergelyCalendar(year, month, day));
2012.5.17. -> Csütörtök [/quote]Sebesség tesztet nem végeztem, szerintem felesleges is.
Szép, de ezt meglehet csinálni hogy a szerveren is mutassa ?
Régen írtam egy hasonlót: http://sampforum.hu/index.php?topic=25799.0