STK UtilSend comments on this topic.
IAgDate Interface

Description

Provides helper methods for a date.

Public Methods

Public Method AddAdds the value in the given unit and returns a new date interface.
Public Method FormatReturns the value of the date given the unit.
Public Method SetDateSets this date with the given date value and unit type.
Public Method SpanSubtracts the value from the IAgDate interface and returns an IAgQuantity.
Public Method SubtractSubtracts the value in the given unit and returns a new date interface.

Public Properties

Public Property OLEDateGets or sets the current time in OLE DATE Format.
Public Property SecIntoDayContains values between 0.0 and 86400 with the exception of when the date is inside a leap second in which case the SecIntoDay can become as large as 86401.0.
Public Property SecIntoDayUTCContains values between 0.0 and 86400 with the exception of when the date is inside a leap second in which case the SecIntoDay can become as large as 86401.0.
Public Property WholeDaysGets or sets the Julian Day Number of the date of interest.
Public Property WholeDaysUTCGets or sets the UTC Day Number of the date of interest.

Example

Calculate date subtraction (with IAgDate)
[C#]
// Create a date representing now
IAgDate nowDate = root.ConversionUtility.NewDate("DD/MM/YYYY", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"));

// Dates can be modified using Subtract 52 days
IAgDate newDate = nowDate.Subtract("day", 52.0);

// Differences between dates are calculated from Span function
IAgQuantity span = newDate.Span(nowDate);

// IAgDate also provides formatting functionalities
span.ConvertToUnit("min");
Console.WriteLine("Date(now) in UTCG is: {0}", nowDate.Format("UTCG"));
Console.WriteLine("Date(52 days before now) in UTCG is: {0}", newDate.Format("UTCG"));
Console.WriteLine("The difference between now and 52 days ago is {0} minutes!", span.Value);
Calculate date addition (with IAgDate)
[C#]
// Create a date representing now
IAgDate nowDate = root.ConversionUtility.NewDate("DD/MM/YYYY", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"));

// Dates can be modified using Add 52 days
IAgDate newDate = nowDate.Add("day", 52.0);

// Differences between dates are calculated from Span function
IAgQuantity span = newDate.Span(nowDate);

// IAgDate also provides formatting functionalities
span.ConvertToUnit("min");
Console.WriteLine("Date(now) in UTCG is: {0}", nowDate.Format("UTCG"));
Console.WriteLine("Date(52 days from now) in UTCG is: {0}", newDate.Format("UTCG"));
Console.WriteLine("The difference between now and 52 days to come is {0} minutes!", span.Value);
Calculate date subtraction (with IAgDate)
[Visual Basic .NET]
' Create a date representing now
Dim nowDate As IAgDate = root.ConversionUtility.NewDate("DD/MM/YYYY", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"))

' Dates can be modified using Subtract 52 days
Dim newDate As IAgDate = nowDate.Subtract("day", 52)

' Differences between dates are calculated from Span function
Dim span As IAgQuantity = newDate.Span(nowDate)

' IAgDate also provides formatting functionalities
span.ConvertToUnit("min")
Console.WriteLine("Date(now) in UTCG is: {0}", nowDate.Format("UTCG"))
Console.WriteLine("Date(52 days before now) in UTCG is: {0}", newDate.Format("UTCG"))
Console.WriteLine("The difference between now and 52 days ago is {0} minutes!", span.Value)
Calculate date addition (with IAgDate)
[Visual Basic .NET]
' Create a date representing now
Dim nowDate As IAgDate = root.ConversionUtility.NewDate("DD/MM/YYYY", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"))

' Dates can be modified using Add 52 days
Dim newDate As IAgDate = nowDate.Add("day", 52)

' Differences between dates are calculated from Span function
Dim span As IAgQuantity = newDate.Span(nowDate)

' IAgDate also provides formatting functionalities
span.ConvertToUnit("min")
Console.WriteLine("Date(now) in UTCG is: {0}", nowDate.Format("UTCG"))
Console.WriteLine("Date(52 days from now) in UTCG is: {0}", newDate.Format("UTCG"))
Console.WriteLine("The difference between now and 52 days to come is {0} minutes!", span.Value)
© 2024 Analytical Graphics, Inc. All Rights Reserved.