Skip to content

ERPConnect.AbapDate

Namespace: ERPConnect
Assembly: ERPConnectStandard20.dll

Represents an SAP date (ABAP type d, or DDIC type DATS).

public readonly struct AbapDate

Inherited Members

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Remarks

The Julian calendar is used from 0001-01-01 to 1582-10-04. The Gregorian calendar is used from 1582-10-15. The date range from 1582-10-05 to 1582-10-14 is invalid.

Constructors

AbapDate(in ushort, in byte, in byte)

Initializes a new instance of ERPConnect.AbapDate using a 1-based year, month and day.

public AbapDate(in ushort year, in byte month, in byte day)

Parameters

year ushort

month byte

day byte

Exceptions

ArgumentOutOfRangeException

The date is invalid. e.g. month 13 or 29.02. in any other year than a leap year.

Properties

Day

Gets the current day in currently represented ERPConnect.AbapDate.Month and ERPConnect.AbapDate.Year.

public byte Day { get; }

Property Value

byte

InitialValue

Gets a constant value representing the initial value (ABAP string 00000000).

public static AbapDate InitialValue { get; }

Property Value

AbapDate

MaxValue

Gets the maximum representable date (9999-12-31).

public static AbapDate MaxValue { get; }

Property Value

AbapDate

MinValue

Gets the minimum representable date (0001-01-01).

public static AbapDate MinValue { get; }

Property Value

AbapDate

Month

Gets the current month in currently represented ERPConnect.AbapDate.Year.

public byte Month { get; }

Property Value

byte

Year

Gets the currently represented year.

public ushort Year { get; }

Property Value

ushort

Methods

IsJulianDate(in ushort, in byte, in byte)

public static bool IsJulianDate(in ushort year, in byte month, in byte day)

Parameters

year ushort

month byte

day byte

Returns

bool

IsLeapYear(in ushort)

Checks whether this year is a leap year. Years before 1582 follow the Julian rule (every 4 years) for leap years, afterwards the Gregorian rule is used for leap years.

public static bool IsLeapYear(in ushort year)

Parameters

year ushort

Returns

bool

Parse(in string)

public static AbapDate Parse(in string abapString)

Parameters

abapString string

Returns

AbapDate

ToString()

public override string ToString()

Returns

string

TryToDateTime(out DateTime?)

Tries to convert to the corresponding System.DateTime value.

public bool TryToDateTime(out DateTime? value)

Parameters

value DateTime?

Returns

bool

Remarks

The ABAP values 0001-01-01 and 0001-01-02 cannot be converted. Assuming the proleptic Julian calendar, they would correspond to 0000-12-30 and 0000-12-31, which is out of range for System.DateTime.

UtcToday()

Gets an ERPConnect.AbapDate representing the current date (UTC).

public static AbapDate UtcToday()

Returns

AbapDate


Last update: January 10, 2024