User Tools

Site Tools


vba:classes:date:dateinterval:index

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vba:classes:date:dateinterval:index [28.08.2015 12:40:01]
yaslaw
vba:classes:date:dateinterval:index [28.06.2016 11:46:59] (current)
yaslaw
Line 1: Line 1:
 <​const>​ <​const>​
-    version=1.2.1 +    version=1.6.0 
-    vdate=26.08.2015+    vdate=21.06.2016
     fname=dateinterval.cls     fname=dateinterval.cls
     ns=%NAMESPACE%     ns=%NAMESPACE%
Line 18: Line 18:
 Grundlage dient [[http://​en.wikipedia.org/​wiki/​Iso8601#​Durations|ISO8601 Duration]] Grundlage dient [[http://​en.wikipedia.org/​wiki/​Iso8601#​Durations|ISO8601 Duration]]
  
-Siehe auch [[vba:​classes:​date:​datetime:​index]] +<note important>​Die Klasse ​[[vba:​classes:​date:​datetime:​index]] ​muss ebenfalls installiert sein:  
-  ​*[[definition]] +{{:​vba:​classes:​date:​datetime.cls|}}</​note>​
-  *[[beispiele]] +
-  *[[code]]+
 <WRAP clear></​WRAP>​ <WRAP clear></​WRAP>​
  
-{{tabinclude>definition+===== Methoden===== 
-beispiele+  *[[#​construct|construct()]]:​ Initialisiert ein Objekt 
-code}}+  *[[#​instance|instance()]]:​ Instanziert & Initialisiert ein Objekt 
 +  *[[#​instancefromdatediff|instanceFromDateDiff()]]:​ Instanziert ein Objekt aus 2 Daten 
 +  *[[#​format|format()]]:​ Formatiert analog zu format() in VBA 
 +  *[[#​format2()|format2()]]:​ Ersetzt Patterns durch Werte 
 +   
 +==== CONSTRUCT() ==== 
 +<code vb>Public Function instance(ByVal iIntervalSpec As Variant) As DateInterval</​code>​ 
 +Initialisiert eine [[.:​index|DateIteratorInstanz]] mit einer [[#​iIntervalSpec|IntervalSpec]] oder Anzahl Tage 
 + 
 +=== Parameters === 
 +== iIntervalSpec == 
 +Eine %%IntervalSpec%% nach [[http://​en.wikipedia.org/​wiki/​Iso8601#​Durations|ISO8601 Duration]]  
 +oder eine Zahl. Das währen dann Anzahlt Tage 
 + 
 +=== Return === 
 +Eine Referenz auf die aktuelle [[.:​index]]-Instanz 
 +=== Beispiel === 
 +<code vb>Dim di As New DateInterval 
 +di.construct ("​P3DT5H"​) 
 +</​code>​ 
 + 
 +==== INSTANCE()==== 
 +<code vb>​Public Function instance(ByVal iIntervalSpec As Variant) As DateInterval</​code>​ 
 +Erstellt eine neue Instanz eines [[.:​index|DateIterators]] aus einer [[#​iIntervalSpec|IntervalSpec]] oder aus Anzahl Tage 
 + 
 +Diese Funktion hat die Attributzeile '​Attribute item.VB_UserMemId = 0'. Ergo ist es die Standartfunktion der Klasse 
 +=== Parameters === 
 +== iIntervalSpec == 
 +Eine %%IntervalSpec%% nach [[http://​en.wikipedia.org/​wiki/​Iso8601#​Durations|ISO8601 Duration]]  
 +oder eine Zahl. Das währen dann Anzahlt Tage 
 + 
 +=== Return === 
 +Eine neue Instanz der [[.:​index]]-Klasse 
 + 
 +=== Beispiele === 
 +<code vb>Dim di As DateInterval 
 +'​Einmal über Funktionsaufruf mit einer IntervalSpec 
 +Set di = DateInterval.instance("​P3D"​) 
 +'Und dasselbe mit Anzahl Tage. Da instance() die Standartfunktion istmuss sie nicht explizit angegeben werden 
 +Set di = DateInterval(3)</​code>​ 
 + 
 +==== INSTANCEFROMDATEDIFF() ==== 
 +Erstellt eine Instance von einem [[.:​index|DateIterar]] aus der Differenz von 2 Datum 
 +<code vb>​Public Function instanceFromDateDiff( _ 
 +        Optional ByRef iDate1 As Variant = Null_ 
 +        ​Optional ByRef iDate2 As Variant = Null, _ 
 +        Optional ByVal iAbsolute As Boolean = False _ 
 +) As DateInterval</​code
 + 
 +=== Parameters === 
 +== iDate1 ==  
 +Das erste Datum für die Differenz. Es kann sich dabei um ein VBA-Datum, ein Datumsstring oder ein [[..:​datetime:​index|DateTime-Objekt]] handeln 
 +== iDate2 ==  
 +Das zweite Datum für die Differenz. Es kann sich dabei um ein VBA-Datum, ein Datumsstring oder ein [[..:​datetime:​index|DateTime-Objekt]] handeln 
 +== iAbsolute == 
 +Ein Flag mit dem man das Vorzeichen unterdrücken kann. Egal ob iDate1 oder iDate2 grösser ist, es wird immer eine positive DIfferenz sofern iAbsolute auf True steht. 
 + 
 +=== Return === 
 +Eine neue Instanz der [[.:​index]]-Klasse 
 + 
 +=== Beispiel === 
 +<code vb>Dim di As DateInterval 
 +Set di = DateInterval.instanceFromDateDiff(#​8/​1/​2014 8:15:00 AM#, #9/1/2014 9:30:15 AM#​)</​code>​ 
 + 
 +==== format() ==== 
 +Formatiert ein Interval zu einem String. Formate analog zum VBA-Befehl format() 
 +<code vb>​Public Function format(ByVal iFormat As String) As String</​code>​ 
 + 
 +=== Parameters === 
 +== iFormat == 
 +Das Ausgabeformat 
 +^ Abk. ^ Beschreibung ^ 
 +| m | Monat ohne führende Null (1-12) | 
 +| mm | Monat mit führende Null (01-12) | 
 +| mx | Total Anzahl Monate ohne führende Null | 
 +| d | Tag ohne führende Null (1-31) | 
 +| dd | Tag mit führende Null (01-31) | 
 +| dx | Total Anzahl Tage ohne führende Null | 
 +| y | Einstelliges Jahr. Analog zu d wird es glösser geschrieben,​ wenn es mehr Zeichen hat | 
 +| yy | Zweistelliges Jahr | 
 +| yyyy | Vierstelliges Jahr | 
 +| h | Stunden ohne führende Null(0-24) | 
 +| hh | Stunden mit führende Null(00-24) | 
 +| hx | Total Anzahl Stunden ohne führende Null | 
 +| n | Minuten ohne führende Null(0-59) | 
 +| nn | Minuten mit führende Null(00-59) | 
 +| nx | Total Anzahl Minuten ohne führende Null | 
 +| s | Sekunden ohne führende Null(0-59) | 
 +| ss | Sekunden mit führende Null(00-59) | 
 +| sx | Total Anzahl Tage ohne führende Null | 
 +| r | Bei Muinus ein - | 
 +| R | Bei Minus ein -, bei Plus ein + | 
 +Mit \ kann ein Format maskiert werden. damit es nichtgeparst wird: m wird als Monat ausgegeben. \m wird zu "​m"​ 
 + 
 +=== Return === 
 +Ein formatierter String 
 + 
 +=== Beispiel === 
 +<code vb>Dim di As DateInterval 
 +Set di = DateInterval("​P13Y4M1DT15H"​) 
 +Debug.Print di.format("​\Y;:​ y, \M: m"​) ​ '-> "Y: 13, M: 4"</​code>​ 
 + 
 +==== format2() ==== 
 +Formatiert ein Interval zu einem String. Im Gegensatz zu format() werden die Formate als Pattern mitgegeben. Dadurch lassen sich Texte einfach parsen. 
 +<code vb>​Public Function format2(ByVal iFormat As String) As String</​code>​ 
 +=== Parameters === 
 +== iFormat == 
 +Die Patterns sind analog zu iFormat bei format(). Jedoch müssen sie in {$..geschrieben werden. 
 + 
 +=== Return === 
 +Ein formatierter String 
 + 
 +=== Beispiel === 
 +<code vb>Dim di As DateInterval 
 +Set di = DateInterval("​P13Y4M1DT15H"​) 
 +Debug.Print di.format2("​Y:​ {$y}, M: {$m}"​) ​ '-> "Y: 13, M: 4"</​code>​ 
 + 
 +===== Properties ===== 
 +  ***year** Die Jahre des Intervals 
 +  ***month** 
 +  ***day** 
 +  ***hour** 
 +  ***minute** 
 +  ***second** 
 +  ***sign** Das Vorzeichen des Interval. -1 oder 1 
 +  ***years** Anzahl Jahre insgesamt. Wird nur bei %%DateDIff%%() abgefüllt. Entspricht dem VBA.%%DateDiff%%('​y',​ date1, date2) 
 +  ***months** Dito für Monate 
 +  ***days** Dito für Tage 
 +  ***hours** Dito für Stunden 
 +  ***minutes** Dito für Minuten 
 +  ***seconds** Dito für Sekunden 
 + 
 +  ***intervalSpec** Gibt den Interval als [[#​intervalspec|IntervalSpec]] zurück: P[n]Y[n]M[n]DT[n]H[n]M[n]S 
 +  ***intervalSpec2** [[#​intervalspec|IntervalSpec]]in der Schreibweise:​ PYYYYMMDDThhmmss 
 +  ***intervalSpec3** und P[YYYY]-[MM]-[DD]T[hh]:​[mm]:​[ss] 
 +   
 +  ===== Code ===== 
 +<source '​%%fpath%%/​%%fname%%'​ vb>
vba/classes/date/dateinterval/index.1440758401.txt.gz · Last modified: 28.08.2015 12:40:01 by yaslaw