DT_UnixTime

DT_UnixTime converts the Unix time value into the date/time format used by UniPlot.

rvDateTime = DT_UnixTime(rvUnixTime)
rvDateTime = DT_UnixTime(rvUnixTime, ssUnit)

Return Value

rvDateTime is a vector with Date/Time values used by UniPlot: Days are represented by whole number increments starting with 31 December 1899, midnight as time zero. Hour values are expressed as the absolute value of the fractional part of the number. In case of an error the function returns -1.

Parameters

rvUnixTime

rvUniTime is a real vector with unix time stamps. The time stamp values are seconds, millseconds or microseconds since 1970-01-01 00:00:00 UTC.

ssUnit

String with the unit text of the given timestamps: s, ms or μs. If this parameter is not specified, the function will calculate the unit as following:

if (all(rvUnixTime > 5e8 && rvUnixTime < 1.9e9)) {  //  05.11.1985 to 17.03.2030
     ssUnit = "s";
} else if (all(rvUnixTime > 5e11 && rvUnixTime < 1.9e12)) {  //  05.11.1985 to 17.03.2030
     ssUnit = "ms"
} else if (all(rvUnixTime > 5e14 && rvUnixTime < 1.9e15)) {  //  05.11.1985 to 17.03.2030
     ssUnit = "μs"
}

Comment

Calculation of UniPlot time:

// days from 01.01.1900 to 01.01.1970: 25569 Days
// Seconds in a day: 86400
if (ssUnit == "s") {
     return rvUnixTime ./ 86400 + 25569;
} else if (ssUnit == "ms") {
     return rvUnixTime ./ (86400 * 1e3) + 25569;
} else if (ssUnit == "μs") {
     return rvUnixTime ./ (86400 * 1e6) + 25569;
}

id-1580356