Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ private DateOnly GetFromBinary(long value)
switch (_webApiConnector.TargetPlatform)
{
case eTargetProjectPlatform.TIAPORTAL:
int val = ((int)value) - 1;
return DateOnly.FromDayNumber(val).AddYears(1989);
//int val = ((int)value) - 1;
return ((int)value).GetDateOnly();//DateOnly.FromDayNumber((int)value).AddYears(1989);

case eTargetProjectPlatform.SIMATICAX:
var valAx = value / 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ public static ConnectorAdapter CreateWebApi(this ConnectorAdapterBuilder adapter
{ Parameters = new object[] { ipAddress, userName, password, customServerCertHandler, ignoreSslErrors, platform, dbName } };
}

public static DateOnly GetDateOnly(this int value)
{
// 1 tick = 100 ns
// Use DateTimeKind.Utc for correct interpretation
var dateTime = new DateTime(1990, 1, 1, 0, 0, 0, DateTimeKind.Utc)
.AddDays(value);

// Return the date portion in UTC
return DateOnly.FromDateTime(dateTime.ToUniversalTime());
}

public static DateOnly GetDateOnly(this long value)
{
// 1 tick = 100 ns
Expand Down