Search Results for

    Show / Hide Table of Contents

    Struct XDate

    This struct encapsulates a date and time value, and handles associated calculations and conversions between various formats.

    Implements
    IComparable
    Inherited Members
    Object.Equals(Object, Object)
    Object.GetType()
    Object.ReferenceEquals(Object, Object)
    Namespace: ZedGraph
    Assembly: ZedGraph.dll
    Syntax
    public struct XDate : IComparable
    Remarks

    This format stored as a double value representing days since a reference date (XL date 0.0 is December 30, 1899 at 00:00 hrs). Negative values are permissible, and the range of valid dates is from noon on January 1st, 4713 B.C. forward. Internally, the date calculations are done using Astronomical Julian Day numbers. The Astronomical Julian Day number is defined as the number of days since noon on January 1st, 4713 B.C. (also referred to as 12:00 on January 1, -4712). NOTE: MS Excel actually has an error in the Serial Date calculations because it errantly assumes 1900 is a leap year. The XDate calculations do not have this same error. Therefore, XDate and Excel Date Serial values are 1 day different up until the date value of 60 (in Excel, this is February 29th, 1900, and in XDate, this is February 28th, 1900). At a value of 61 (March 1st, 1900) or greater, they agree with eachother.

    Constructors

    | Improve this Doc View Source

    XDate(DateTime)

    Construct a date class from a DateTime struct.

    Declaration
    public XDate(DateTime dateTime)
    Parameters
    Type Name Description
    DateTime dateTime

    A DateTime struct containing the initial date information.

    | Improve this Doc View Source

    XDate(Double)

    Construct a date class from an XL date value.

    Declaration
    public XDate(double xlDate)
    Parameters
    Type Name Description
    Double xlDate

    An XL Date value in floating point double format

    | Improve this Doc View Source

    XDate(Int32, Int32, Int32)

    Construct a date class from a calendar date (year, month, day). Assumes the time of day is 00:00 hrs

    Declaration
    public XDate(int year, int month, int day)
    Parameters
    Type Name Description
    Int32 year

    An integer value for the year, e.g., 1995.

    Int32 month

    An integer value for the month of the year, e.g., 8 for August. It is permissible to have months outside of the 1-12 range, which will rollover to the previous or next year.

    Int32 day

    An integer value for the day of the month, e.g., 23. It is permissible to have day numbers outside of the 1-31 range, which will rollover to the previous or next month and year.

    | Improve this Doc View Source

    XDate(Int32, Int32, Int32, Int32, Int32, Double)

    Construct a date class from a calendar date and time (year, month, day, hour, minute, second), where seconds is a Double value (allowing fractional seconds).

    Declaration
    public XDate(int year, int month, int day, int hour, int minute, double second)
    Parameters
    Type Name Description
    Int32 year

    An integer value for the year, e.g., 1995.

    Int32 month

    An integer value for the month of the year, e.g., 8 for August. It is permissible to have months outside of the 1-12 range, which will rollover to the previous or next year.

    Int32 day

    An integer value for the day of the month, e.g., 23. It is permissible to have day numbers outside of the 1-31 range, which will rollover to the previous or next month and year.

    Int32 hour

    An integer value for the hour of the day, e.g. 15. It is permissible to have hour values outside the 0-23 range, which will rollover to the previous or next day.

    Int32 minute

    An integer value for the minute, e.g. 45. It is permissible to have hour values outside the 0-59 range, which will rollover to the previous or next hour.

    Double second

    A double value for the second, e.g. 35.75. It is permissible to have second values outside the 0-59 range, which will rollover to the previous or next minute.

    | Improve this Doc View Source

    XDate(Int32, Int32, Int32, Int32, Int32, Int32)

    Construct a date class from a calendar date and time (year, month, day, hour, minute, second).

    Declaration
    public XDate(int year, int month, int day, int hour, int minute, int second)
    Parameters
    Type Name Description
    Int32 year

    An integer value for the year, e.g., 1995.

    Int32 month

    An integer value for the month of the year, e.g., 8 for August. It is permissible to have months outside of the 1-12 range, which will rollover to the previous or next year.

    Int32 day

    An integer value for the day of the month, e.g., 23. It is permissible to have day numbers outside of the 1-31 range, which will rollover to the previous or next month and year.

    Int32 hour

    An integer value for the hour of the day, e.g. 15. It is permissible to have hour values outside the 0-23 range, which will rollover to the previous or next day.

    Int32 minute

    An integer value for the minute, e.g. 45. It is permissible to have hour values outside the 0-59 range, which will rollover to the previous or next hour.

    Int32 second

    An integer value for the second, e.g. 35. It is permissible to have second values outside the 0-59 range, which will rollover to the previous or next minute.

    | Improve this Doc View Source

    XDate(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

    Construct a date class from a calendar date and time (year, month, day, hour, minute, second, millisecond).

    Declaration
    public XDate(int year, int month, int day, int hour, int minute, int second, int millisecond)
    Parameters
    Type Name Description
    Int32 year

    An integer value for the year, e.g., 1995.

    Int32 month

    An integer value for the month of the year, e.g., 8 for August. It is permissible to have months outside of the 1-12 range, which will rollover to the previous or next year.

    Int32 day

    An integer value for the day of the month, e.g., 23. It is permissible to have day numbers outside of the 1-31 range, which will rollover to the previous or next month and year.

    Int32 hour

    An integer value for the hour of the day, e.g. 15. It is permissible to have hour values outside the 0-23 range, which will rollover to the previous or next day.

    Int32 minute

    An integer value for the minute, e.g. 45. It is permissible to have hour values outside the 0-59 range, which will rollover to the previous or next hour.

    Int32 second

    An integer value for the second, e.g. 35. It is permissible to have second values outside the 0-59 range, which will rollover to the previous or next minute.

    Int32 millisecond

    An integer value for the millisecond, e.g. 632. It is permissible to have millisecond values outside the 0-999 range, which will rollover to the previous or next second.

    | Improve this Doc View Source

    XDate(XDate)

    The Copy Constructor

    Declaration
    public XDate(XDate rhs)
    Parameters
    Type Name Description
    XDate rhs

    The GraphPane object from which to copy

    Fields

    | Improve this Doc View Source

    DefaultFormatStr

    The default format string to be used in ToString() when no format is provided

    Declaration
    public const string DefaultFormatStr = "g"
    Field Value
    Type Description
    String
    | Improve this Doc View Source

    HoursPerDay

    The number of hours in a day

    Declaration
    public const double HoursPerDay = 24
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    JulDayMax

    The maximum valid Julian Day, which corresponds to December 31st, 9999 A.D.

    Declaration
    public const double JulDayMax = 5373483.5
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    JulDayMin

    The minimum valid Julian Day, which corresponds to January 1st, 4713 B.C.

    Declaration
    public const double JulDayMin = 0
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    MillisecondsPerDay

    The number of milliseconds in a day

    Declaration
    public const double MillisecondsPerDay = 86400000
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    MillisecondsPerSecond

    The number of milliseconds in a second

    Declaration
    public const double MillisecondsPerSecond = 1000
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    MinutesPerDay

    The number of minutes in a day

    Declaration
    public const double MinutesPerDay = 1440
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    MinutesPerHour

    The number of minutes in an hour

    Declaration
    public const double MinutesPerHour = 60
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    MonthsPerYear

    The number of months in a year

    Declaration
    public const double MonthsPerYear = 12
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    SecondsPerDay

    The number of seconds in a day

    Declaration
    public const double SecondsPerDay = 86400
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    SecondsPerMinute

    The number of seconds in a minute

    Declaration
    public const double SecondsPerMinute = 60
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    XLDay1

    The Astronomical Julian Day number that corresponds to XL Date 0.0

    Declaration
    public const double XLDay1 = 2415018.5
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    XLDayMax

    The maximum valid Excel Day, which corresponds to December 31st, 9999 A.D.

    Declaration
    public const double XLDayMax = 2958465
    Field Value
    Type Description
    Double
    | Improve this Doc View Source

    XLDayMin

    The minimum valid Excel Day, which corresponds to January 1st, 4713 B.C.

    Declaration
    public const double XLDayMin = -2415018.5
    Field Value
    Type Description
    Double

    Properties

    | Improve this Doc View Source

    DateTime

    Gets or sets the date value for this item in .Net DateTime format.

    Declaration
    public DateTime DateTime { get; set; }
    Property Value
    Type Description
    DateTime
    | Improve this Doc View Source

    DecimalYear

    Gets or sets the decimal year number (i.e., 1997.345) corresponding to this item.

    Declaration
    public double DecimalYear { get; set; }
    Property Value
    Type Description
    Double
    | Improve this Doc View Source

    IsValidDate

    Returns true if this XDate struct is in the valid date range

    Declaration
    public bool IsValidDate { get; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    JulianDay

    Gets or sets the date value for this item in Julain day format. This is the Astronomical Julian Day number, so a value of 0.0 corresponds to noon GMT on January 1st, -4712. Thus, Julian Day number 2,400,000.0 corresponds to noon GMT on November 16, 1858.

    Declaration
    public double JulianDay { get; set; }
    Property Value
    Type Description
    Double
    | Improve this Doc View Source

    XLDate

    Gets or sets the date value for this item in MS Excel format.

    Declaration
    public double XLDate { get; set; }
    Property Value
    Type Description
    Double

    Methods

    | Improve this Doc View Source

    AddDays(Double)

    Add the specified number of days (can be fractional) to the current XDate instance.

    Declaration
    public void AddDays(double dDays)
    Parameters
    Type Name Description
    Double dDays

    The incremental number of days (negative or positive) in floating point double format.

    | Improve this Doc View Source

    AddHours(Double)

    Add the specified number of hours (can be fractional) to the current XDate instance.

    Declaration
    public void AddHours(double dHours)
    Parameters
    Type Name Description
    Double dHours

    The incremental number of hours (negative or positive) in floating point double format.

    | Improve this Doc View Source

    AddMilliseconds(Double)

    Add the specified number of milliseconds (can be fractional) to the current XDate instance.

    Declaration
    public void AddMilliseconds(double dMilliseconds)
    Parameters
    Type Name Description
    Double dMilliseconds

    The incremental number of milliseconds (negative or positive) in floating point double format.

    | Improve this Doc View Source

    AddMinutes(Double)

    Add the specified number of minutes (can be fractional) to the current XDate instance.

    Declaration
    public void AddMinutes(double dMinutes)
    Parameters
    Type Name Description
    Double dMinutes

    The incremental number of minutes (negative or positive) in floating point double format.

    | Improve this Doc View Source

    AddMonths(Double)

    Add the specified number of Months (can be fractional) to the current XDate instance.

    Declaration
    public void AddMonths(double dMonths)
    Parameters
    Type Name Description
    Double dMonths

    The incremental number of months (negative or positive) in floating point double format.

    | Improve this Doc View Source

    AddSeconds(Double)

    Add the specified number of seconds (can be fractional) to the current XDate instance.

    Declaration
    public void AddSeconds(double dSeconds)
    Parameters
    Type Name Description
    Double dSeconds

    The incremental number of seconds (negative or positive) in floating point double format.

    | Improve this Doc View Source

    AddYears(Double)

    Add the specified number of years (can be fractional) to the current XDate instance.

    Declaration
    public void AddYears(double dYears)
    Parameters
    Type Name Description
    Double dYears

    The incremental number of years (negative or positive) in floating point double format.

    | Improve this Doc View Source

    CalendarDateToJulianDay(Int32, Int32, Int32, Int32, Int32, Int32)

    Calculate an Astronomical Julian Day number from the specified Calendar date (year, month, day, hour, minute, second), first normalizing all input data values

    Declaration
    public static double CalendarDateToJulianDay(int year, int month, int day, int hour, int minute, int second)
    Parameters
    Type Name Description
    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Int32 second

    The integer second value (e.g., 42 for 42 seconds past the minute).

    Returns
    Type Description
    Double

    The corresponding Astronomical Julian Day number, expressed in double floating point format

    | Improve this Doc View Source

    CalendarDateToJulianDay(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

    Calculate an Astronomical Julian Day number from the specified Calendar date (year, month, day, hour, minute, second), first normalizing all input data values

    Declaration
    public static double CalendarDateToJulianDay(int year, int month, int day, int hour, int minute, int second, int millisecond)
    Parameters
    Type Name Description
    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Int32 second

    The integer second value (e.g., 42 for 42 seconds past the minute).

    Int32 millisecond

    The integer second value (e.g., 325 for 325 milliseconds past the minute).

    Returns
    Type Description
    Double

    The corresponding Astronomical Julian Day number, expressed in double floating point format

    | Improve this Doc View Source

    CalendarDateToXLDate(Int32, Int32, Int32, Int32, Int32, Double)

    Calculate an XL Date from the specified Calendar date (year, month, day, hour, minute, second), first normalizing all input data values. The seconds value is a double type, allowing fractional seconds.

    Declaration
    public static double CalendarDateToXLDate(int year, int month, int day, int hour, int minute, double second)
    Parameters
    Type Name Description
    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Double second

    The double second value (e.g., 42.3 for 42.3 seconds past the minute).

    Returns
    Type Description
    Double

    The corresponding XL date, expressed in double floating point format

    Remarks

    The Calendar date is always based on the Gregorian Calendar. Note that the Gregorian calendar is really only valid from October 15, 1582 forward. The countries that adopted the Gregorian calendar first did so on October 4, 1582, so that the next day was October 15, 1582. Prior to that time the Julian Calendar was used. However, Prior to March 1, 4 AD the treatment of leap years was inconsistent, and prior to 45 BC the Julian Calendar did not exist. The XDate struct projects only Gregorian dates backwards and does not deal with Julian calendar dates at all. The ToString(Double, String) method will just append a "(BC)" notation to the end of any dates prior to 1 AD, since the DateTime struct throws an exception when formatting earlier dates.

    | Improve this Doc View Source

    CalendarDateToXLDate(Int32, Int32, Int32, Int32, Int32, Int32)

    Calculate an XL Date from the specified Calendar date (year, month, day, hour, minute, second), first normalizing all input data values.

    Declaration
    public static double CalendarDateToXLDate(int year, int month, int day, int hour, int minute, int second)
    Parameters
    Type Name Description
    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Int32 second

    The integer second value (e.g., 42 for 42 seconds past the minute).

    Returns
    Type Description
    Double

    The corresponding XL date, expressed in double floating point format

    Remarks

    The Calendar date is always based on the Gregorian Calendar. Note that the Gregorian calendar is really only valid from October 15, 1582 forward. The countries that adopted the Gregorian calendar first did so on October 4, 1582, so that the next day was October 15, 1582. Prior to that time the Julian Calendar was used. However, Prior to March 1, 4 AD the treatment of leap years was inconsistent, and prior to 45 BC the Julian Calendar did not exist. The XDate struct projects only Gregorian dates backwards and does not deal with Julian calendar dates at all. The ToString(Double, String) method will just append a "(BC)" notation to the end of any dates prior to 1 AD, since the DateTime struct throws an exception when formatting earlier dates.

    | Improve this Doc View Source

    CalendarDateToXLDate(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

    Calculate an XL Date from the specified Calendar date (year, month, day, hour, minute, second), first normalizing all input data values.

    Declaration
    public static double CalendarDateToXLDate(int year, int month, int day, int hour, int minute, int second, int millisecond)
    Parameters
    Type Name Description
    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Int32 second

    The integer second value (e.g., 42 for 42 seconds past the minute).

    Int32 millisecond

    The integer millisecond value (e.g., 374 for 374 milliseconds past the second).

    Returns
    Type Description
    Double

    The corresponding XL date, expressed in double floating point format

    Remarks

    The Calendar date is always based on the Gregorian Calendar. Note that the Gregorian calendar is really only valid from October 15, 1582 forward. The countries that adopted the Gregorian calendar first did so on October 4, 1582, so that the next day was October 15, 1582. Prior to that time the Julian Calendar was used. However, Prior to March 1, 4 AD the treatment of leap years was inconsistent, and prior to 45 BC the Julian Calendar did not exist. The XDate struct projects only Gregorian dates backwards and does not deal with Julian calendar dates at all. The ToString(Double, String) method will just append a "(BC)" notation to the end of any dates prior to 1 AD, since the DateTime struct throws an exception when formatting earlier dates.

    | Improve this Doc View Source

    CompareTo(Object)

    Compares one XDate object to another.

    Declaration
    public int CompareTo(object target)
    Parameters
    Type Name Description
    Object target

    The second XDate object to be compared.

    Returns
    Type Description
    Int32

    zero if target is equal to the current instance, -1 if target is less than the current instance, and 1 if target is greater than the current instance.

    Remarks

    This method will throw an exception if target is not an XDate object.

    | Improve this Doc View Source

    DateTimeToXLDate(DateTime)

    Convert a .Net DateTime struct to an XL Format date

    Declaration
    public static double DateTimeToXLDate(DateTime dt)
    Parameters
    Type Name Description
    DateTime dt

    The date value in the form of a .Net DateTime struct

    Returns
    Type Description
    Double

    The corresponding XL Date, expressed in double floating point format

    | Improve this Doc View Source

    DecimalYearToXLDate(Double)

    Calculate a decimal year value (e.g., 1994.6523) corresponding to the specified XL date

    Declaration
    public static double DecimalYearToXLDate(double yearDec)
    Parameters
    Type Name Description
    Double yearDec

    The decimal year value in floating point double format.

    Returns
    Type Description
    Double

    The corresponding XL Date, expressed in double floating point format

    | Improve this Doc View Source

    Equals(Object)

    Tests whether obj is either an XDate structure or a double floating point value that is equal to the same date as this XDate struct instance.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    The object to compare for equality with this XDate instance. This object should be either a type XDate or type double.

    Returns
    Type Description
    Boolean

    Returns true if obj is the same date as this instance; otherwise, false

    Overrides
    ValueType.Equals(Object)
    | Improve this Doc View Source

    GetDate(out Int32, out Int32, out Int32)

    Get the calendar date (year, month, day) corresponding to this instance.

    Declaration
    public void GetDate(out int year, out int month, out int day)
    Parameters
    Type Name Description
    Int32 year

    An integer value for the year, e.g., 1995.

    Int32 month

    An integer value for the month of the year, e.g., 8 for August.

    Int32 day

    An integer value for the day of the month, e.g., 23.

    | Improve this Doc View Source

    GetDate(out Int32, out Int32, out Int32, out Int32, out Int32, out Int32)

    Get the calendar date (year, month, day, hour, minute, second) corresponding to this instance.

    Declaration
    public void GetDate(out int year, out int month, out int day, out int hour, out int minute, out int second)
    Parameters
    Type Name Description
    Int32 year

    An integer value for the year, e.g., 1995.

    Int32 month

    An integer value for the month of the year, e.g., 8 for August.

    Int32 day

    An integer value for the day of the month, e.g., 23.

    Int32 hour

    An integer value for the hour of the day, e.g. 15.

    Int32 minute

    An integer value for the minute, e.g. 45.

    Int32 second

    An integer value for the second, e.g. 35.

    | Improve this Doc View Source

    GetDayOfYear()

    Get the day of year value (241.345 means the 241st day of the year) corresponding to this instance.

    Declaration
    public double GetDayOfYear()
    Returns
    Type Description
    Double

    The day of the year in floating point double format.

    | Improve this Doc View Source

    GetHashCode()

    Returns the hash code for this XDate structure. In this case, the hash code is simply the equivalent hash code for the floating point double date value.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    An integer representing the hash code for this XDate value

    Overrides
    ValueType.GetHashCode()
    | Improve this Doc View Source

    JulianDayToCalendarDate(Double, out Int32, out Int32, out Int32, out Int32, out Int32, out Double)

    Calculate a Calendar date (year, month, day, hour, minute, second) corresponding to the Astronomical Julian Day number

    Declaration
    public static void JulianDayToCalendarDate(double jDay, out int year, out int month, out int day, out int hour, out int minute, out double second)
    Parameters
    Type Name Description
    Double jDay

    The Astronomical Julian Day number to be converted

    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Double second

    The double second value (e.g., 42.3 for 42.3 seconds past the minute).

    | Improve this Doc View Source

    JulianDayToCalendarDate(Double, out Int32, out Int32, out Int32, out Int32, out Int32, out Int32)

    Calculate a Calendar date (year, month, day, hour, minute, second) corresponding to the Astronomical Julian Day number

    Declaration
    public static void JulianDayToCalendarDate(double jDay, out int year, out int month, out int day, out int hour, out int minute, out int second)
    Parameters
    Type Name Description
    Double jDay

    The Astronomical Julian Day number to be converted

    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Int32 second

    The integer second value (e.g., 42 for 42 seconds past the minute).

    | Improve this Doc View Source

    JulianDayToCalendarDate(Double, out Int32, out Int32, out Int32, out Int32, out Int32, out Int32, out Double)

    Calculate a Calendar date (year, month, day, hour, minute, second) corresponding to the Astronomical Julian Day number

    Declaration
    public static void JulianDayToCalendarDate(double jDay, out int year, out int month, out int day, out int hour, out int minute, out int second, out double millisecond)
    Parameters
    Type Name Description
    Double jDay

    The Astronomical Julian Day number to be converted

    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Int32 second

    The integer second value (e.g., 42 for 42 seconds past the minute).

    Double millisecond

    The Double millisecond value (e.g., 342.5 for 342.5 milliseconds past the second).

    | Improve this Doc View Source

    JulianDayToXLDate(Double)

    Calculate an XL Date corresponding to the specified Astronomical Julian Day number

    Declaration
    public static double JulianDayToXLDate(double jDay)
    Parameters
    Type Name Description
    Double jDay

    The Astronomical Julian Day number in floating point double format.

    Returns
    Type Description
    Double

    The corresponding XL Date, expressed in double floating point format

    | Improve this Doc View Source

    MakeValidDate(Double)

    Take the specified date, and bound it to the valid date range for the XDate struct.

    Declaration
    public static double MakeValidDate(double xlDate)
    Parameters
    Type Name Description
    Double xlDate

    The date to be bounded

    Returns
    Type Description
    Double

    An XLDate value that lies between the minimum and maximum valid date ranges (see XLDayMin and XLDayMax)

    | Improve this Doc View Source

    SetDate(Int32, Int32, Int32)

    Set the calendar date (year, month, day) of this instance.

    Declaration
    public void SetDate(int year, int month, int day)
    Parameters
    Type Name Description
    Int32 year

    An integer value for the year, e.g., 1995.

    Int32 month

    An integer value for the month of the year, e.g., 8 for August.

    Int32 day

    An integer value for the day of the month, e.g., 23.

    | Improve this Doc View Source

    SetDate(Int32, Int32, Int32, Int32, Int32, Int32)

    Set the calendar date (year, month, day, hour, minute, second) of this instance.

    Declaration
    public void SetDate(int year, int month, int day, int hour, int minute, int second)
    Parameters
    Type Name Description
    Int32 year

    An integer value for the year, e.g., 1995.

    Int32 month

    An integer value for the month of the year, e.g., 8 for August.

    Int32 day

    An integer value for the day of the month, e.g., 23.

    Int32 hour

    An integer value for the hour of the day, e.g. 15.

    Int32 minute

    An integer value for the minute, e.g. 45.

    Int32 second

    An integer value for the second, e.g. 35.

    | Improve this Doc View Source

    ToString()

    Format this XDate value using the default format string (see cref="DefaultFormatStr"/>).

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    A string representation of the date

    Overrides
    ValueType.ToString()
    Remarks

    The formatting is done using the DateTime ToString(String) method in order to provide full localization capability. The DateTime struct is limited to dates from 1 AD onward. However, all calendar dates in XDate and DateTime are projected Gregorian calendar dates. Since the Gregorian calendar was not implemented until October 4, 1582 (or later in some countries), Gregorian dates prior to that time are really dates that would have been, had the Gregorian calendar existed. In order to avoid throwing an exception, for dates prior to 1 AD, the year will be converted to a positive year and the text "(BC)" is appended to the end of the formatted string. Under this mode, the year sequence is 2BC, 1BC, 1AD, 2AD, etc. There is no year zero.

    | Improve this Doc View Source

    ToString(Double)

    Format this XDate value using the default format string (DefaultFormatStr).

    Declaration
    public string ToString(double xlDate)
    Parameters
    Type Name Description
    Double xlDate

    The XL date value to be formatted in floating point double format.

    Returns
    Type Description
    String

    A string representation of the date

    Remarks

    The formatting is done using the DateTime ToString(String) method in order to provide full localization capability. The DateTime struct is limited to dates from 1 AD onward. However, all calendar dates in XDate and DateTime are projected Gregorian calendar dates. Since the Gregorian calendar was not implemented until October 4, 1582 (or later in some countries), Gregorian dates prior to that time are really dates that would have been, had the Gregorian calendar existed. In order to avoid throwing an exception, for dates prior to 1 AD, the year will be converted to a positive year and the text "(BC)" is appended to the end of the formatted string. Under this mode, the year sequence is 2BC, 1BC, 1AD, 2AD, etc. There is no year zero.

    | Improve this Doc View Source

    ToString(Double, String)

    Format the specified XL Date value using the specified format string. The format string is specified according to the DateTime class.

    Declaration
    public static string ToString(double xlDate, string fmtStr)
    Parameters
    Type Name Description
    Double xlDate

    The XL date value to be formatted in floating point double format.

    String fmtStr

    The formatting string to be used for the date. See DateTimeFormatInfo for a list of the format types available.

    Returns
    Type Description
    String

    A string representation of the date

    Remarks

    The formatting is done using the DateTime ToString(String) method in order to provide full localization capability. The DateTime struct is limited to dates from 1 AD onward. However, all calendar dates in XDate and DateTime are projected Gregorian calendar dates. Since the Gregorian calendar was not implemented until October 4, 1582 (or later in some countries), Gregorian dates prior to that time are really dates that would have been, had the Gregorian calendar existed. In order to avoid throwing an exception, for dates prior to 1 AD, the year will be converted to a positive year and the text "(BC)" is appended to the end of the formatted string. Under this mode, the year sequence is 2BC, 1BC, 1AD, 2AD, etc. There is no year zero.

    | Improve this Doc View Source

    ToString(String)

    Format this XL Date value using the specified format string. The format string is specified according to the DateTime class.

    Declaration
    public string ToString(string fmtStr)
    Parameters
    Type Name Description
    String fmtStr

    The formatting string to be used for the date. See DateTimeFormatInfo class for a list of the format types available.

    Returns
    Type Description
    String

    A string representation of the date

    Remarks

    The formatting is done using the DateTime ToString(String) method in order to provide full localization capability. The DateTime struct is limited to dates from 1 AD onward. However, all calendar dates in XDate and DateTime are projected Gregorian calendar dates. Since the Gregorian calendar was not implemented until October 4, 1582 (or later in some countries), Gregorian dates prior to that time are really dates that would have been, had the Gregorian calendar existed. In order to avoid throwing an exception, for dates prior to 1 AD, the year will be converted to a positive year and the text "(BC)" is appended to the end of the formatted string. Under this mode, the year sequence is 2BC, 1BC, 1AD, 2AD, etc. There is no year zero.

    | Improve this Doc View Source

    XLDateToCalendarDate(Double, out Int32, out Int32, out Int32, out Int32, out Int32, out Double)

    Calculate a Calendar date (year, month, day, hour, minute, second) corresponding to the specified XL date

    Declaration
    public static void XLDateToCalendarDate(double xlDate, out int year, out int month, out int day, out int hour, out int minute, out double second)
    Parameters
    Type Name Description
    Double xlDate

    The XL date value in floating point double format.

    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Double second

    The double second value (e.g., 42.3 for 42.3 seconds past the minute).

    | Improve this Doc View Source

    XLDateToCalendarDate(Double, out Int32, out Int32, out Int32, out Int32, out Int32, out Int32)

    Calculate a Calendar date (year, month, day, hour, minute, second) corresponding to the specified XL date

    Declaration
    public static void XLDateToCalendarDate(double xlDate, out int year, out int month, out int day, out int hour, out int minute, out int second)
    Parameters
    Type Name Description
    Double xlDate

    The XL date value in floating point double format.

    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Int32 second

    The integer second value (e.g., 42 for 42 seconds past the minute).

    | Improve this Doc View Source

    XLDateToCalendarDate(Double, out Int32, out Int32, out Int32, out Int32, out Int32, out Int32, out Int32)

    Calculate a Calendar date (year, month, day, hour, minute, second) corresponding to the specified XL date

    Declaration
    public static void XLDateToCalendarDate(double xlDate, out int year, out int month, out int day, out int hour, out int minute, out int second, out int millisecond)
    Parameters
    Type Name Description
    Double xlDate

    The XL date value in floating point double format.

    Int32 year

    The integer year value (e.g., 1994).

    Int32 month

    The integer month value (e.g., 7 for July).

    Int32 day

    The integer day value (e.g., 19 for the 19th day of the month).

    Int32 hour

    The integer hour value (e.g., 14 for 2:00 pm).

    Int32 minute

    The integer minute value (e.g., 35 for 35 minutes past the hour).

    Int32 second

    The integer second value (e.g., 42 for 42 seconds past the minute).

    Int32 millisecond

    The integer millisecond value (e.g., 325 for 325 milliseconds past the second).

    | Improve this Doc View Source

    XLDateToDateTime(Double)

    Convert an XL date format to a .Net DateTime struct

    Declaration
    public static DateTime XLDateToDateTime(double xlDate)
    Parameters
    Type Name Description
    Double xlDate

    The XL date value in floating point double format.

    Returns
    Type Description
    DateTime

    The corresponding XL Date, expressed in double floating point format

    | Improve this Doc View Source

    XLDateToDayOfWeek(Double)

    Calculate a day-of-week value (e.g., Sun=0, Mon=1, Tue=2, etc.) corresponding to the specified XL date

    Declaration
    public static int XLDateToDayOfWeek(double xlDate)
    Parameters
    Type Name Description
    Double xlDate

    The XL date value in floating point double format.

    Returns
    Type Description
    Int32

    The corresponding day-of-week (DoW) value, expressed in integer format

    | Improve this Doc View Source

    XLDateToDayOfYear(Double)

    Calculate a day-of-year value (e.g., 241.543 corresponds to the 241st day of the year) corresponding to the specified XL date

    Declaration
    public static double XLDateToDayOfYear(double xlDate)
    Parameters
    Type Name Description
    Double xlDate

    The XL date value in floating point double format.

    Returns
    Type Description
    Double

    The corresponding day-of-year (DoY) value, expressed in double floating point format

    | Improve this Doc View Source

    XLDateToDecimalYear(Double)

    Calculate a decimal year value (e.g., 1994.6523) corresponding to the specified XL date

    Declaration
    public static double XLDateToDecimalYear(double xlDate)
    Parameters
    Type Name Description
    Double xlDate

    The XL date value in floating point double format.

    Returns
    Type Description
    Double

    The corresponding decimal year value, expressed in double floating point format

    | Improve this Doc View Source

    XLDateToJulianDay(Double)

    Calculate an Astronomical Julian Day number corresponding to the specified XL date

    Declaration
    public static double XLDateToJulianDay(double xlDate)
    Parameters
    Type Name Description
    Double xlDate

    The XL date value in floating point double format.

    Returns
    Type Description
    Double

    The corresponding Astronomical Julian Day number, expressed in double floating point format

    Operators

    | Improve this Doc View Source

    Addition(XDate, Double)

    '+' operator overload. When a double value is added to an XDate, the result is a new XDate with the number of days added.

    Declaration
    public static XDate operator +(XDate lhs, double rhs)
    Parameters
    Type Name Description
    XDate lhs

    The left-hand-side of the '-' operator (an XDate class)

    Double rhs

    The right-hand-side of the '+' operator (a double value)

    Returns
    Type Description
    XDate

    An XDate with the rhs number of days added

    | Improve this Doc View Source

    Decrement(XDate)

    '--' operator overload. Decrement the date by one day.

    Declaration
    public static XDate operator --(XDate xDate)
    Parameters
    Type Name Description
    XDate xDate

    The XDate struct on which to operate

    Returns
    Type Description
    XDate

    An XDate one day prior to the specified date

    | Improve this Doc View Source

    Implicit(DateTime to XDate)

    Implicit conversion from DateTime to XDate.

    Declaration
    public static implicit operator XDate(DateTime dt)
    Parameters
    Type Name Description
    DateTime dt

    The DateTime struct on which to operate

    Returns
    Type Description
    XDate

    An XDate struct representing the specified DateTime value.

    | Improve this Doc View Source

    Implicit(Double to XDate)

    Implicit conversion from double (an XL Date) to XDate.

    Declaration
    public static implicit operator XDate(double xlDate)
    Parameters
    Type Name Description
    Double xlDate

    The XDate struct on which to operate

    Returns
    Type Description
    XDate

    An XDate struct representing the specified xlDate value.

    | Improve this Doc View Source

    Implicit(XDate to DateTime)

    Implicit conversion from XDate to DateTime.

    Declaration
    public static implicit operator DateTime(XDate xDate)
    Parameters
    Type Name Description
    XDate xDate

    The XDate struct on which to operate

    Returns
    Type Description
    DateTime

    A DateTime struct representing the specified xDate value.

    | Improve this Doc View Source

    Implicit(XDate to Double)

    Implicit conversion from XDate to double (an XL Date).

    Declaration
    public static implicit operator double (XDate xDate)
    Parameters
    Type Name Description
    XDate xDate

    The XDate struct on which to operate

    Returns
    Type Description
    Double

    A double floating point value representing the XL Date

    | Improve this Doc View Source

    Implicit(XDate to Single)

    Implicit conversion from XDate to float (an XL Date).

    Declaration
    public static implicit operator float (XDate xDate)
    Parameters
    Type Name Description
    XDate xDate

    The XDate struct on which to operate

    Returns
    Type Description
    Single

    A double floating point value representing the XL Date

    | Improve this Doc View Source

    Increment(XDate)

    '++' operator overload. Increment the date by one day.

    Declaration
    public static XDate operator ++(XDate xDate)
    Parameters
    Type Name Description
    XDate xDate

    The XDate struct on which to operate

    Returns
    Type Description
    XDate

    An XDate one day later than the specified date

    | Improve this Doc View Source

    Subtraction(XDate, Double)

    '-' operator overload. When a double value is subtracted from an XDate, the result is a new XDate with the number of days subtracted.

    Declaration
    public static XDate operator -(XDate lhs, double rhs)
    Parameters
    Type Name Description
    XDate lhs

    The left-hand-side of the '-' operator (an XDate class)

    Double rhs

    The right-hand-side of the '-' operator (a double value)

    Returns
    Type Description
    XDate

    An XDate with the rhs number of days subtracted

    | Improve this Doc View Source

    Subtraction(XDate, XDate)

    '-' operator overload. When two XDates are subtracted, the number of days between dates is returned.

    Declaration
    public static double operator -(XDate lhs, XDate rhs)
    Parameters
    Type Name Description
    XDate lhs

    The left-hand-side of the '-' operator (an XDate class)

    XDate rhs

    The right-hand-side of the '-' operator (an XDate class)

    Returns
    Type Description
    Double

    The days between dates, expressed as a floating point double

    Implements

    System.IComparable
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX