Skip to content

ERPConnect.AbapTimestamp

Namespace: ERPConnect
Assembly: ERPConnectStandard20.dll

Represents an SAP timestamp, similar to System.DateTime. Accuracy is ticks (100 nanoseconds). Both packed numbers (data elements TIMESTAMP, TIMESTAMPL) and native (type utclong) representations are supported.

public readonly struct AbapTimestamp : IComparable, IComparable<AbapTimestamp>, IEquatable<AbapTimestamp>

Implements

IComparable, IComparable<AbapTimestamp>, IEquatable<AbapTimestamp>

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

AbapTimestamp(in ulong)

Initializes a new instance of ERPConnect.AbapTimestamp from total ticks (100 nanoseconds passed since 01.01.0001).

public AbapTimestamp(in ulong ticks)

Parameters

ticks ulong

Exceptions

ArgumentOutOfRangeException

Ticks are outside the valid min or max range

AbapTimestamp(in ushort, in byte, in byte)

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

public AbapTimestamp(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.

AbapTimestamp(in ushort, in byte, in byte, in TimeSpan)

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

public AbapTimestamp(in ushort year, in byte month, in byte day, in TimeSpan time)

Parameters

year ushort

month byte

day byte

time TimeSpan

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.AbapTimestamp.Month and ERPConnect.AbapTimestamp.Year.

public byte Day { get; }

Property Value

byte

InitialValue

Gets a constant value representing the initial value (0 ticks).

public static AbapTimestamp InitialValue { get; }

Property Value

AbapTimestamp

MaxValue

Gets the maximum representable date and time. Currently this is 31.12.9999 23:59:59.99999999

public static AbapTimestamp MaxValue { get; }

Property Value

AbapTimestamp

MinValue

Gets the minimum representable date and time. Currently this is 01.01.0001 00:00:00.0000000

public static AbapTimestamp MinValue { get; }

Property Value

AbapTimestamp

Month

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

public byte Month { get; }

Property Value

byte

Ticks

Gets the total ticks. A single tick represents 100 nanoseconds since 01.01.0001.

public ulong Ticks { get; }

Property Value

ulong

Time

Gets the current time of day.

public TimeSpan Time { get; }

Property Value

TimeSpan

Year

Gets the currently represented year.

public ushort Year { get; }

Property Value

ushort

Methods

AddDays(in int)

Adds (or subtracts) the specified amount of days from the currently represented date and time.

public AbapTimestamp AddDays(in int days)

Parameters

days int

Returns

AbapTimestamp

Exceptions

ArgumentOutOfRangeException

The resulting ERPConnect.AbapTimestamp is out of range of a representable date

AddHours(in int)

Adds (or subtracts) the specified amount of hours from the currently represented date and time.

public AbapTimestamp AddHours(in int hours)

Parameters

hours int

Returns

AbapTimestamp

Exceptions

ArgumentOutOfRangeException

The resulting ERPConnect.AbapTimestamp is out of range of a representable date

AddMinutes(in long)

Adds (or subtracts) the specified amount of minutes from the currently represented date and time.

public AbapTimestamp AddMinutes(in long minutes)

Parameters

minutes long

Returns

AbapTimestamp

Exceptions

ArgumentOutOfRangeException

The resulting ERPConnect.AbapTimestamp is out of range of a representable date

AddSeconds(in long)

Adds (or subtracts) the specified amount of seconds from the currently represented date and time.

public AbapTimestamp AddSeconds(in long seconds)

Parameters

seconds long

Returns

AbapTimestamp

Exceptions

ArgumentOutOfRangeException

The resulting ERPConnect.AbapTimestamp is out of range of a representable date

AddTicks(in long)

public AbapTimestamp AddTicks(in long ticks)

Parameters

ticks long

Returns

AbapTimestamp

CompareTo(AbapTimestamp)

public int CompareTo(AbapTimestamp other)

Parameters

other AbapTimestamp

Returns

int

CompareTo(object)

public int CompareTo(object obj)

Parameters

obj object

Returns

int

Equals(AbapTimestamp)

public bool Equals(AbapTimestamp other)

Parameters

other AbapTimestamp

Returns

bool

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

FromPackedNumber(in decimal)

public static AbapTimestamp FromPackedNumber(in decimal packedNumber)

Parameters

packedNumber decimal

Returns

AbapTimestamp

GetHashCode()

public override int GetHashCode()

Returns

int

Parse(in string)

public static AbapTimestamp Parse(in string abapString)

Parameters

abapString string

Returns

AbapTimestamp

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.

UtcNow()

Gets an ERPConnect.AbapTimestamp representing the current date and time (UTC).

public static AbapTimestamp UtcNow()

Returns

AbapTimestamp

UtcToday()

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

public static AbapTimestamp UtcToday()

Returns

AbapTimestamp

Operators

operator +(AbapTimestamp, AbapTimestamp)

public static AbapTimestamp operator +(AbapTimestamp a, AbapTimestamp b)

Parameters

a AbapTimestamp

b AbapTimestamp

Returns

AbapTimestamp

operator ==(AbapTimestamp, AbapTimestamp)

public static bool operator ==(AbapTimestamp a, AbapTimestamp b)

Parameters

a AbapTimestamp

b AbapTimestamp

Returns

bool

operator >(AbapTimestamp, AbapTimestamp)

public static bool operator >(AbapTimestamp a, AbapTimestamp b)

Parameters

a AbapTimestamp

b AbapTimestamp

Returns

bool

operator !=(AbapTimestamp, AbapTimestamp)

public static bool operator !=(AbapTimestamp a, AbapTimestamp b)

Parameters

a AbapTimestamp

b AbapTimestamp

Returns

bool

operator <(AbapTimestamp, AbapTimestamp)

public static bool operator <(AbapTimestamp a, AbapTimestamp b)

Parameters

a AbapTimestamp

b AbapTimestamp

Returns

bool

operator -(AbapTimestamp, AbapTimestamp)

public static AbapTimestamp operator -(AbapTimestamp a, AbapTimestamp b)

Parameters

a AbapTimestamp

b AbapTimestamp

Returns

AbapTimestamp