English
Source / code snippets

Berechnungen Erwünscht Calendar Mitwirkung

 

Michael
Wodrich
[size=18:9a05d71d8c]Calendar-Berechnungen:[/size:9a05d71d8c]
(written in XProfan; must evtl. a little bit angepaßt go for frühere versions)

there's sure many Opportunities for management of Kalenderdaten.
here go some routines pictured, a LongInt-Variable to Speicherung using.

that this possible is show I here:

2147483647 maximum positiver LongInt-worth
..CCYYMMDD the date becomes so stored
..hhmmsscc The Time becomes so stored

CC...... The centenary-indicated (Century)
..YY.... the year
....MM.. the month
......DD the day

hh...... The hour
..mm.... The Minute
....ss.. The second
......cc The Hundertstel-second (Centi)


The Profan-internen date- and Zeitfunktionen can herewith well complement go.

The subesquent routines building Date and Time together:
CompileMarkSeparation
Def MakeFullDate(3) (@&(3)*10000)+(@&(2)*100)+@&(1)
Def MakeDate(4)     (@&(3)*1000000)+(@&(4)*10000)+(@&(2)*100)+@&(1)
Def MakeTime(4)     (@&(1)*1000000)+(@&(2)*10000)+(@&(3)*100)+@&(4)re>
Syntax:
CompileMarkSeparation
Datum& = MakeFullDate(Tag&,Monat&,Jahr&) z.B.: dat& = MakeFullDate(4,6,2004)
Datum& = MakeDate(Tag&,Monat&,Jahrhundert&,Jahr&) z.B.: dat& = MakeDate(4,6,20,04)
Zeit& = MakeTime(Stunde&,Minute&,Sekunde&,Hundertstel&) z.B.: tim& = MakeTime(23,30,0,40)re>
decompose the Datums in its Einzelteile (Parameter is the LongInt-date):
CompileMarkSeparation
Def GetFullYear(1) @Int(@&(1) / 10000)
Def GetCentury(1)  @Int(@&(1) / 1000000)
Def GetYear(1)     @Int((@&(1) mod 1000000) / 10000)
Def GetMonth(1)    @Int((@&(1) mod 10000) / 100)
Def GetDay(1)      @Int(@&(1) mod 100)/pre>
decompose the Time in your Einzelteile (Parameter is the LongInt-worth):
CompileMarkSeparation
Def GetHour(1)     @Int(@&(1) / 1000000)
Def GetMinute(1)   @Int((@&(1) mod 1000000) / 10000)
Def GetSecond(1)   @Int((@&(1) mod 10000) / 100)
Def GetCenti(1)    @Int(@&(1) mod 100)pre>
date- and Time-compare:
(d1 - date the 1. Wertes)
(t1 - Time the 1. Wertes)
(d2 - date the 2. Wertes)
(t2 - Time the 2. Wertes)
CompileMarkSeparation
Def Time_EQ(d1,t1,d2,t2)  (@&(1) = @&(3)) and (@&(2) = @&(4))
Def Time_GE(d1,t1,d2,t2)  (@&(1) > @&(3)) or ((@&(1) = @&(3)) and (@&(2) >= @&(4)))
Def Time_GT(d1,t1,d2,t2)  (@&(1) > @&(3)) or ((@&(1) = @&(3)) and (@&(2) > @&(4)))
Def Time_LE(d1,t1,d2,t2)  (@&(1) < @&(3)) or ((@&(1) = @&(3)) and (@&(2) <= @&(4)))
Def Time_LT(d1,t1,d2,t2)  (@&(1) < @&(3)) or ((@&(1) = @&(3)) and (@&(2) < @&(4)))
Def Time_NEQ(d1,t1,d2,t2) (@&(1) <> @&(3)) or (@&(2) <> @&(4))
the actually date serviert Profan already mundgerecht:
CompileMarkSeparationwith the actually Time must one already a little bit More nachhelfen:
CompileMarkSeparationis the angegebene year one leap-year?
it go too years to the Kalenderreform correctly examined:
CompileMarkSeparation
Proc IsLeapYear

    checks, whether the angegebene year one leap-year is.
    it must too the centenary indicated go, because "80" means "80 A.D."
    Parameters Year%
    Declare Erg%

    If Year% > 1582

        Erg% = (((Year% mod 4)=0) and ((Year% mod 100)<>0)) or ((Year% mod 400)=0)

    Else

        Erg% = (((Year% mod 4)=0) and ((Year% mod 100)<>0))

    EndIf

    Return Erg%

ENDPROC

determined whom week-day:
CompileMarkSeparation
Proc DayOfWeek

    supply whom week-day.
    0-sunday, 1-monday, ..., 6-saturday
    Parameters Date&
    Declare Year%,Month%,Day&
    Year% = @GetFullYear(Date&)
    Month% = @GetMonth(Date&)
    Day& = @GetDay(Date&)

    If Month% > 2

        Sub Month%,2

    Else

        Add Month%,10
        Dec Year%

    EndIf

    Day& = ((13 * Month% - 1) / 5) + Day% + (Year% mod 100) + ((Year% mod 100) / 4) + ((Year% / 100) / 4) - 2 * (Year% / 100) + 77
    Return (Day& mod 7)

ENDPROC


MfG
Michael Wodrich
 
Programmieren, das spannendste Detektivspiel der Welt.
06/05/04  
 



pointed!, we wars I to the principle a Datums-Distance there, which The Number of years,months,days between two Datumsangaben returns?
 
06/05/04  
 




Michael
Wodrich
through Umrechnung into Julianische Tageszahl. The is really a Float-number. I wanted to the Whole in LongInt keep, but since is the worm drin. time see, I poste the thing on the afternoon time.
now Have I unfortunately no Streichhölzer More, around the eyes aufzuhalten...

To then
Michael Wodrich
 
Programmieren, das spannendste Detektivspiel der Welt.
06/07/04  
 




Sven
Bader
i will really too only The distance zweiter data Perhaps is the for somebody interestingly, The Number of days one month's, Schaltjahrprüfung for february is too thereby.

Def days(2) int(28+val(mid$(303232332323,&(1),1))+if((&(1)=2) & (&(2) MOD 4 = 0),1,0))

appeal: print days(02,2004)
spending: 29 february 2004 having 29 days
 
06/12/06  
 



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

3.900 Views

Untitledvor 0 min.
Ernst10/07/16
Georg Teles01/21/15
Michael Wodrich02/21/14
Pedro Miguel08/26/13
More...

Themeninformationen



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