AGI STK Util 11 Send comments on this topic.
IAgDate Interface





Description

Provides helper methods for a date.

Object Model


Public Methods

Public Method Add Adds the value in the given unit and returns a new date interface.
Public Method Format Returns the value of the date given the unit.
Public Method SetDate Sets this date with the given date value and unit type.
Public Method Span Subtracts the value from the IAgDate interface and returns an IAgQuantity.
Public Method Subtract Subtracts the value in the given unit and returns a new date interface.

Public Properties

Public Property OLEDate The current time in OLE DATE Format.
Public Property SecIntoDay Contains 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 SecIntoDayUTC Contains 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 WholeDays The Julian Day Number of the date of interest.
Public Property WholeDaysUTC The UTC Day Number of the date of interest.

Example

Calculate date subtraction (with IAgDate)
[C#] Copy Code
// 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#] Copy Code
// 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] Copy Code
' Create a date representing now
#If Not CSToJava Then
Dim nowDate As IAgDate = root.ConversionUtility.NewDate("DD/MM/YYYY", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"))
#Else
#End If

' 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] Copy Code
' Create a date representing now
#If Not CSToJava Then
Dim nowDate As IAgDate = root.ConversionUtility.NewDate("DD/MM/YYYY", DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"))
#Else
#End If

' 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)

© 2016 Analytical Graphics, Inc. All Rights Reserved.

STK Programming Interface 11.0.1