Aktív témák
-
Rover623
félisten
Itt egy másik megoldás a Dr Dobbs Journal-ból, 1990-ből...
Egy Zeller nevű csóka algoritmusa 1887-ből...!
Felhívom a figyelmet az angol nyelvű kommentekre:
{ Here's Zeller's seminal black magic: }
{ DON'T KNOW WHY HE DID THIS! }
Function CalcDayOfWeek(Year, Month, Day : Integer) : Integer;
Var
Century,
Holder : Integer;
begin
{ First test For error conditions on input values: }
if (Year < 0) or (Month < 1) or (Month > 12) or (Day < 1) or (Day > 31) then
CalcDayOfWeek := -1 { Return -1 to indicate an error }
else
{ Do the Zeller's Congruence calculation as Zeller himself }
{ described it in ''Acta Mathematica'' #7, Stockhold, 1887. }
begin
{ First we separate out the year and the century figures: }
Century := Year div 100;
Year := Year MOD 100;
{ Next we adjust the month such that March remains month #3, }
{ but that January and February are months #13 and #14, }
{ *but of the previous year*: }
if Month < 3 then
begin
Inc(Month, 12);
if Year > 0 then
Dec(Year, 1) { The year before 2000 is }
else { 1999, not 20-1... }
begin
Year := 99;
Dec(Century);
end;
end;
{ Here's Zeller's seminal black magic: }
Holder := Day; { Start With the day of month }
Holder := Holder + (((Month + 1) * 26) div 10); { Calc the increment }
Holder := Holder + Year; { Add in the year }
Holder := Holder + (Year div 4); { Correct For leap years }
Holder := Holder + (Century div 4); { Correct For century years }
Holder := Holder - Century - Century; { DON'T KNOW WHY HE DID THIS! }
{***********************KLUDGE ALERT!***************************}
While Holder < 0 do { Get negative values up into }
Inc(Holder, 7); { positive territory before }
{ taking the MOD... }
Holder := Holder MOD 7; { Divide by 7 but keep the }
{ remainder rather than the }
{ quotient }
{***********************KLUDGE ALERT!***************************}
{ Here we ''wrap'' Saturday around to be the last day: }
if Holder = 0 then
Holder := 7;
{ Zeller kept the Sunday = 1 origin; computer weenies prefer to }
{ start everything With 0, so here's a 20th century kludge: }
Dec(Holder);
CalcDayOfWeek := Holder; { Return the end product! }
end;
end;
Szóval nem egyértelmű...ja, ez 1582 és 4902 között műx
[Szerkesztve]
Aktív témák
- Parkside szerszám kibeszélő
- AMD K6-III, és minden ami RETRO - Oldschool tuning
- Milyen billentyűzetet vegyek?
- Crimson Desert
- Ford topik
- Motorolaj, hajtóműolaj, hűtőfolyadék, adalékok és szűrők topikja
- Amlogic S905, S912 processzoros készülékek
- AMD Ryzen 9 / 7 / 5 / 3 5***(X) "Zen 3" (AM4)
- BestBuy ruhás topik
- Lenovo Thinkbook, Yoga széria
- További aktív témák...
- 27% - GIGABYTE MO34WQC2 Karcos OLED Monitor! 3440x1440 / 240hz / 0.03ms / FreeSync!
- Lenovo ThinkPad T15 G1 laptop i7, 16GB RAM, 512GB SSD, 1 év garancia Magyar billentyűzet
- Playstation 4 VR V2 eladó!
- Dell Pro 14 PC14250 14" FHD+ IPS érintő Ultra 5 235U 16GB 256GB NVMe ujjlolv IR kam gar
- ELADÓ Radtel RT-920 (10W, CB sáv) többsávos kézi amatőr adóvevő
- Dobozos Új Dell Xps 15 9530 i7 13620h 16gb ram 1tb ssd intel uhd graphics+ Intel Arc A370M
- ÁRGARANCIA!Épített KomPhone i5 14600KF 16/32/64GB RAM RTX 5070 12GB GAMER PC termékbeszámítással
- Ddr5 Laptop Ram 32 gb 2x16gb 5600Mt/s
- HIBÁTLAN iPhone 14 128GB Starlight-1 ÉV GARANCIA - Kártyafüggetlen, MS4650
- Beszámítás! VALVE INDEX virtuális valóság szemüveg garanciával hibátlan működéssel
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest

