• API Overview
  • EBICS API
  • FinTS API
  • XS2A API
  • SEPA API
Search Results for

    Struct SwiftDate

    Represents a special SWIFT date with support for virtual dates such as February, 30th and which can be all zeroes.

    Implements
    System.IComparable
    Inherited Members
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: Subsembly.Swift
    Assembly: Subsembly.Sepa.dll
    Syntax
    public struct SwiftDate : IComparable
    Remarks

    In a null date all components, the Year, the Month, and the Day are zero. The method IsNull can be used to easily check for a null date. The method SetNull() can be used to set a date to null. A newly constructed und uninitialised instance of the SwiftDate structure contains all zeroes which is represents the null date.

    Depending on the chosen SWIFT representation not all components of the date may be given. For example the format SwiftDateMMDD does not have a Year component. In such cases, any missing components will simply be zero.

    According to SWIFT, any two digit year representations YY are always expanded to a full four digit year using the following rule: If YY > 79 then Year = 19YY, else Year = 20YY.

    Constructors

    SwiftDate(DateTime)

    Constructs a SwiftDate instance from the given System.DateTime instance.

    Declaration
    public SwiftDate(DateTime aDateTime)
    Parameters
    Type Name Description
    System.DateTime aDateTime

    A System.DateTime instance that provides the date for the new SwiftDate instance.

    Remarks

    If the given DateTime value is DateTime.MinValue, then the new SwiftDate will be a logical null value.

    SwiftDate(Int32)

    Declaration
    public SwiftDate(int nPackedDate)
    Parameters
    Type Name Description
    System.Int32 nPackedDate

    SwiftDate(Int32, Int32, Int32)

    Constructs a SwiftDate instance with a valid given date.

    Declaration
    public SwiftDate(int nYear, int nMonth, int nDay)
    Parameters
    Type Name Description
    System.Int32 nYear

    Year in the range from 1 through 9999.

    System.Int32 nMonth

    Month in the range from 1 through 12.

    System.Int32 nDay

    Day of month in the range from 1 through 31, regardless of the month. A date specification such as 31st of April is allowed.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    If any of the arguments is outside the allowed range, then an ArgumentOutOfRangeException will be thrown.

    Fields

    MaxDate

    The maximum date is 31.12.9999.

    Declaration
    public static readonly SwiftDate MaxDate
    Field Value
    Type Description
    SwiftDate

    MinDate

    The minimum date is 01.01.0001.

    Declaration
    public static readonly SwiftDate MinDate
    Field Value
    Type Description
    SwiftDate

    NullDate

    Represents a null date.

    Declaration
    public static readonly SwiftDate NullDate
    Field Value
    Type Description
    SwiftDate

    Properties

    Day

    The day in month of this date.

    Declaration
    public int Day { get; set; }
    Property Value
    Type Description
    System.Int32

    This allowed range of this property is 1 through 31, regardless of the month. The value zero is returned for a logical null date, but cannot be set.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    An attempt to set the month to a value outside of the allowed range 1 through 31 will cause an ArgumentOutOfRangeException to be thrown.

    IsNull

    Indicates whether this SwiftDate instance is logically null.

    Declaration
    public readonly bool IsNull { get; }
    Property Value
    Type Description
    System.Boolean

    Month

    The month of this date.

    Declaration
    public int Month { get; set; }
    Property Value
    Type Description
    System.Int32

    This allowed range of this property is 1 through 12. The value zero is returned for a logical null date, but cannot be set.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    An attempt to set the month to a value outside of the allowed range 1 through 12 will cause an ArgumentOutOfRangeException to be thrown.

    Now

    A new SwiftDate for the current date.

    Declaration
    public static readonly SwiftDate Now { get; }
    Property Value
    Type Description
    SwiftDate

    PackedDate

    Declaration
    public readonly int PackedDate { get; }
    Property Value
    Type Description
    System.Int32

    Year

    The year of this date.

    Declaration
    public int Year { get; set; }
    Property Value
    Type Description
    System.Int32

    This valid range of this property is 1 through 9999. The value zero is returned for a logical null date, but cannot be set.

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    An attempt to set the year to a value outside of the allowed range 1 through 9999 will cause an ArgumentOutOfRangeException to be thrown.

    Methods

    AddDays(Int32)

    Safely add or subtract a number of days to this date.

    Declaration
    public SwiftDate AddDays(int nDays)
    Parameters
    Type Name Description
    System.Int32 nDays

    Number of days to add. If negative, then the number of days that is subtracted.

    Returns
    Type Description
    SwiftDate
    Remarks

    If adding or subtract the days would result in a date exeeding MaxDate or MinDate, then this method just returns MaxDate or MinDate and does not throw an exception.

    CompareTo(Object)

    Implements IComparable.CompareTo.

    Declaration
    public int CompareTo(object obj)
    Parameters
    Type Name Description
    System.Object obj

    Other SwiftDate to compare to.

    Returns
    Type Description
    System.Int32

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj
    Returns
    Type Description
    System.Boolean
    Overrides
    System.ValueType.Equals(System.Object)

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    System.ValueType.GetHashCode()

    Parse(String)

    Converts a string in the format YYYYMMDD to a SwiftDate.

    Declaration
    public static SwiftDate Parse(string sStringDate)
    Parameters
    Type Name Description
    System.String sStringDate
    Returns
    Type Description
    SwiftDate
    Remarks

    This is an overloaded convenience method that internally just calls Parse(String, SwiftDateFormat) requesting the YYYYMMDD format.

    Parse(String, SwiftDateFormat)

    Parses a string date according to the specified format.

    Declaration
    public static SwiftDate Parse(string sStringDate, SwiftDateFormat nFormat)
    Parameters
    Type Name Description
    System.String sStringDate

    Date to be parsed according to the specified format.

    SwiftDateFormat nFormat

    Date format that the given string should have.

    Returns
    Type Description
    SwiftDate

    Returns a new instance of the SwiftDate class that is initialised with the parsed date. If the parameter sStringDate is null or an empty string, then NullDate is returned.

    Remarks

    If a format with only a two digit year is parsed, then the century is determined according to SWIFT rules, i.e. if YY > 79 then century is 1900, otherwise the century is 2000.

    If a partial date format, e.g. MMDD or YYMM is parsed, then any unspecified date component will be zero.

    In any format the special case of an all zero date is accepted and will produce a NullDate result.

    Exceptions
    Type Condition
    System.FormatException

    If the given string is not in the specified format, or the month or the day are outside of the allowed range, then a FormatException is thrown.

    System.ArgumentException

    The parameter nFormat did specify an unknown format value.

    SetNull()

    Set this date to a logical null value.

    Declaration
    public void SetNull()

    ToDateTime()

    Attempts to convert this SwiftDate into a System.DateTime value.

    Declaration
    public DateTime ToDateTime()
    Returns
    Type Description
    System.DateTime

    System.DateTime value that is the same as this SwiftDate. The time portion of that value is all zero (midnight). A null date is returned as DateTime.MinValue, a MaxDate is returned as DateTime.MaxValue.

    Remarks

    Not all dates that can be represented in a SwiftDate can be converted correctly into a System.DateTime value. In particular, a null date or a virtual date cannot be converted. Thus virtual dates will be converted to the last real day of the month. A null date will return DateTime.MinValue.

    See Also
    ToDateTime(SwiftTime)

    ToDateTime(SwiftTime)

    Attempts to convert this SwiftDate and SwiftTime into a combined System.DateTime value.

    Declaration
    public DateTime ToDateTime(SwiftTime tTime)
    Parameters
    Type Name Description
    SwiftTime tTime

    The time of the day that shall be contained in the resulting DateTime. May be NullTime.

    Returns
    Type Description
    System.DateTime
    See Also
    ToDateTime()

    ToString()

    Converts this date to a string in the format YYYYMMDD.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    Returns the converted date.

    Overrides
    System.ValueType.ToString()
    Remarks

    This is an overloaded convenience method that internally just calls ToString(SwiftDateFormat) requesting the YYYYMMDD format.

    ToString(SwiftDateFormat)

    Converts this date to a string representation in the format specified.

    Declaration
    public string ToString(SwiftDateFormat nDateFormat)
    Parameters
    Type Name Description
    SwiftDateFormat nDateFormat

    Selects the format to be used for the generated date string.

    Returns
    Type Description
    System.String

    Returns the converted date.

    TryParse(String)

    Declaration
    public static SwiftDate TryParse(string sStringDate)
    Parameters
    Type Name Description
    System.String sStringDate
    Returns
    Type Description
    SwiftDate

    TryParse(String, SwiftDateFormat)

    Tries to parse the given string as a date in the requested format.

    Declaration
    public static SwiftDate TryParse(string sStringDate, SwiftDateFormat nFormat)
    Parameters
    Type Name Description
    System.String sStringDate
    SwiftDateFormat nFormat
    Returns
    Type Description
    SwiftDate

    If parsing fails, this method does not throw an exception, but rather returns NullDate.

    See Also
    Parse(String, SwiftDateFormat)

    Operators

    Equality(SwiftDate, SwiftDate)

    Declaration
    public static bool operator ==(SwiftDate lhs, SwiftDate rhs)
    Parameters
    Type Name Description
    SwiftDate lhs
    SwiftDate rhs
    Returns
    Type Description
    System.Boolean

    GreaterThan(SwiftDate, SwiftDate)

    Declaration
    public static bool operator>(SwiftDate lhs, SwiftDate rhs)
    Parameters
    Type Name Description
    SwiftDate lhs
    SwiftDate rhs
    Returns
    Type Description
    System.Boolean

    GreaterThanOrEqual(SwiftDate, SwiftDate)

    Declaration
    public static bool operator >=(SwiftDate lhs, SwiftDate rhs)
    Parameters
    Type Name Description
    SwiftDate lhs
    SwiftDate rhs
    Returns
    Type Description
    System.Boolean

    Inequality(SwiftDate, SwiftDate)

    Declaration
    public static bool operator !=(SwiftDate lhs, SwiftDate rhs)
    Parameters
    Type Name Description
    SwiftDate lhs
    SwiftDate rhs
    Returns
    Type Description
    System.Boolean

    LessThan(SwiftDate, SwiftDate)

    Declaration
    public static bool operator <(SwiftDate lhs, SwiftDate rhs)
    Parameters
    Type Name Description
    SwiftDate lhs
    SwiftDate rhs
    Returns
    Type Description
    System.Boolean

    LessThanOrEqual(SwiftDate, SwiftDate)

    Declaration
    public static bool operator <=(SwiftDate lhs, SwiftDate rhs)
    Parameters
    Type Name Description
    SwiftDate lhs
    SwiftDate rhs
    Returns
    Type Description
    System.Boolean

    Implements

    System.IComparable
    In This Article
    Back to top Copyright 2009-2025 Subsembly GmbH