Sekunden seit einem bestimmten Datum / Unix-zeit
Folgender Code rechnet die vergangenen Sekunden, die seit einem bestimmten Datum (hier 1. januar 1970 0:00h) vergangen sind, in eine lesbare Datums- und Zeitangabe um:
Code:
function Int32x32To64(const a, b: dword): int64;
begin Result := int64(a) * int64(b); end; function SecsToDateTime(secs: int64): String; var ft : TFILETIME; st : TSYSTEMTIME; lt : TSYSTEMTIME; li : int64; buf1, buf2 : array[0..255] of Char; begin if secs = 0 then begin result := ''; exit; end; st.wYear := 1970; st.wMonth := 1; st.wDayOfWeek := 0; st.wDay := 1; st.wHour := 1; st.wMinute := 0; st.wSecond := 0; st.wMilliseconds := 0; SystemTimeToFileTime(st,ft); { Version 1 } {ui.QuadPart := Int32x32To64(PUserInfo11(ui11)^.usri11_last_logon, 10000000) + 116444736000000000; FileTimeToSystemTime(TFileTime(ui),st); FileTimeToSystemTime(TFileTime(ui),st);} { Version 2 } li := Int32x32To64(secs, 10000000) + 116444736000000000; ft.dwLowDateTime := DWORD(li); ft.dwHighDateTime := li shr 32; FileTimeToSystemTime(TFileTime(ft),st); SystemTimeToTzSpecificLocalTime(nil, st, lt); GetTimeFormat(LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT, @lt, nil, buf1, sizeof(buf1)); GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, @lt, nil, buf2, sizeof(buf2)); result := String(buf2)+' / '+String(buf1); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:58 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz