English
Source / code snippets

Kalenderwoche from date to charge

 

p.specht

In EU-europe begins The count the Wochentage of/ one (Arbeits-)week with monday = 1. The first Kalenderwoche is those, with the The überwiegende number of Meet already in the ongoing year lying, if the New Year's Day So one thursday or later is. therefore comes in the nachfolgenden Program the Berechnung the Wochentagsnummer the Neujahrstages particular weight To.

an spending KW=0 means then, that the sought day yet to 53. week the Vorjahres counts. The Algorithmus operates ex the 01.01.1583 and is of Unix-Jahr_2038-Error not concerned.

Zit. Wiki: " each year has either 52 or 53 Kalenderwochen.
- One Normaljahr with 53 weeks begins in a thursday and end in a thursday.
- One leap-year with 53 weeks begins either in a wednesday and end in a thursday or it begins in a thursday and end in a friday.
- - The 29., 30. and 31. december can already to Kalenderwoche 1 the Folgejahres belong.
- - The 1., 2. and 3. january can yet to the last Kalenderwoche the Vorjahres belong."


DIN 1355-1 led to that 1. january 1976 a suitable Zählweise with monday as first week-day in the german Sprachraum one.
Window Title upper$("Europäische Kalenderwochennummer one designed Datums")
Window Style 24:declare jahr&,monat&,tag&:font 2'BETA-VERSION OHNE EACH GEWÄHR!
looop:
CLS:print "\n  year = ";:input jahr&:print " month = ";:input monat&
print "   day = ";:input tag&:print

if WTNr(jahr&,monat&,tag&)<1:print " Eingabefehler! (Jahr<1583 o.ähnl.)":goto "resum":endif

    casenot SJ(jahr&):print " Kein";:print " leap-year!"
    print " this ";TN(jahr&,monat&,tag&);".day the Jahres";
    print " lying in the ";KW(jahr&,monat&,tag&);".KW";
    case KW(jahr&,monat&,tag&)=0:print " or. The 53.KW the Vorjahres,";
    print "\n and is the ";WTNr(jahr&,monat&,tag&);".day this week (count begins with Mo)."
    print " it deals itself circa a ";WTStr$(WTNr(jahr&,monat&,tag&));" (";WTsStr$(WTNr(jahr&,monat&,tag&));")"
    resum:
    print:waitinput:goto "Looop"
    END

    proc SJ :parameters jahr&:case jahr&<1583:return -1'SCHALTJAHR

        var sj&=0:ifnot jahr& mod 4:sj&=1:ifnot jahr& mod 100:sj&=0
        casenot jahr& mod 400:sj&=1:endif:endif:return sj&

    endproc

    proc TN :parameters jahr&,monat&,tag&'TAGNUMMER IN JAHR

        case (jahr&<1583) or (monat&<1) or (monat&>12):return -1
        var tn&=val(substr$("0 31 59 90 120 151 181 212 243 273 304 334 365",monat&," "))+tag&
        case monat&<3:return tn&:case SJ(jahr&):inc tn&:return tn&

    endproc

    proc WTNr :parameters jahr&,monat&,tag&

        case jahr&<1583:return -1'WOCHENTAG-Nr
        var WTNrNJ&=WTNrNJ(jahr&)
        var TN&=TN(jahr&,monat&,tag&)
        var WTNr& = ( ((TN&-1) mod 7)+(WTNrNJ&-1)) mod 7 + 1
        return WTNr&

    endproc

    proc WTsStr$ :parameters WTNr&'WOCHENTAG-shortString

        return substr$("Mo Di wen Do Fr Sa So",WTNr&," ")

    endproc

    proc WTStr$ :parameters WTNr& :return substr$(\

        "Montag tuesday wednesday thursday friday saturday Sonntag",WTNr&," ")

    endproc' = WOCHENTAG-NAME

    proc WTNrNJ :parameters jahr&'WOCHENTAG-Nr_des_Neujahrstages

        case jahr&<1583:return -1:var AJ&=jahr&-1201
        var WT&=1+AJ&+int(AJ&/4)-int(AJ&/100)+int(AJ&/400)
        WT&=WT& mod 7: case wt&=0:wt&=7:return WT&' 1="Montag"

    endproc

    Proc KW :parameters jahr&,monat&,tag&

        var WT&=WTNrNJ(jahr&)'KALENDERWOCHE
        var WN&=TN(jahr&,monat&,tag&)+WT&-2
        case WT&<5:WN&=WN&+7
        WN&=int(WN&/7):return WN&

    endproc

 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/20/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.402 Views

Untitledvor 0 min.
Karl von Weizen vor 18 Tagen
Hans Neff01/24/23
Rschnett08/06/22
p.specht07/31/22
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie