Daylight saving time/de
Sommerzeitberechnung der Bundesrepublik Deutschland ab dem Jahr 1981.
Die Funktion prüft, ob das übergebene Datum in der Sommerzeit liegt (Rückgabewert: True).
function funIstSommerzeit(Datum: TDateTime): boolean;
var
wrdJahr: word;
wrdMonat: word;
wrdTag: word;
datSommerzeit: TDatetime;
datWinterzeit: TDateTime;
begin
Result := False;
DecodeDate(Datum, wrdJahr, wrdMonat, wrdTag);
if wrdJahr < 1981 then
exit;
// Beginn der Sommerzeit:
// letzter Sonntag im März um 2:00 Uhr
datSommerzeit := EncodeDate(wrdJahr, 3, 31);
datSommerzeit := datSommerzeit - (DayOfWeek(datSommerzeit) - 1) +
Frac(StrToTime('02:00'));
// Ende der Sommerzeit:
// von 1981 bis 1995 letzter Sonntag im September um 3:00 Uhr
// ab 1996 letzter Sonntag im Oktober um 3:00 Uhr
if wrdJahr <= 1995 then
datWinterzeit := EncodeDate(wrdJahr, 9, 30)
else
datWinterzeit := EncodeDate(wrdJahr, 10, 31);
datWinterzeit := datWinterzeit - (DayOfWeek(datWinterzeit) - 1) +
Frac(StrToTime('03:00'));
Result := (Datum >= datSommerzeit) and (Datum < datWinterzeit);
end;Beispiel für einen Aufruf der Funktion:
uses
...DateUtils...
function funTest: string;
begin
// 10. Oktober 1990, 14:34:56
if funIstSommerzeit(EncodeDateTime(1990,10,10,14,34,56,00);) = False then
Result := 'Normalzeit'
else
Result := 'Sommerzeit';
end;From the Free Pascal wiki, page "Daylight saving time/de", as it stood on 2020-02-12 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Edited on wiki.freepascal.org by 5 people, 2013–2020
From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.
| When | Who | What changed |
|---|---|---|
| Olaf | Created page | |
| Olaf | (minor) | |
| Olaf | (minor) | |
| BigChimp | Unified Windows and Linux calls for clarity. | |
| Jwdietrich | moved Summertime/de to Daylight saving time/de: The correct english term for the German word "Sommerzeit" is "Daylight saving time". (minor) | |
| Jwdietrich | ||
| FTurtle | ||
| FTurtle | ||
| Trev | Fixed syntax highlighting; deleted category already in page template (minor) |
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
